-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicUsage.jsx
More file actions
84 lines (74 loc) · 1.96 KB
/
BasicUsage.jsx
File metadata and controls
84 lines (74 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from 'react';
import {
UbidotsProvider,
useUbidotsReady,
useUbidotsSelectedDevice,
useUbidotsActions,
} from '@ubidots/react-html-canvas';
import './styles.css';
function DeviceInfo() {
const ready = useUbidotsReady();
const device = useUbidotsSelectedDevice();
const { setDashboardDevice, refreshDashboard } = useUbidotsActions();
if (!ready) {
return (
<div className='loading'>
<p>🔄 Loading Ubidots connection...</p>
</div>
);
}
return (
<div className='content'>
<h2>📱 Device Information</h2>
{device ? (
<div className='device-info'>
<h3>Current Device</h3>
<p>
<strong>ID:</strong> {device.id}
</p>
<p>
<strong>Name:</strong> {device.name}
</p>
<p>
<strong>Label:</strong> {device.label}
</p>
<details className='device-details'>
<summary>View all properties</summary>
<pre className='device-json'>{JSON.stringify(device, null, 2)}</pre>
</details>
</div>
) : (
<div className='no-device'>
<p>⚠️ No device selected</p>
</div>
)}
<div className='button-group'>
<button
onClick={() => setDashboardDevice('example-device-id')}
className='button-primary'
>
Select Example Device
</button>
<button onClick={refreshDashboard} className='button-success'>
🔄 Refresh Dashboard
</button>
</div>
</div>
);
}
export function BasicUsage() {
return (
<UbidotsProvider>
<div className='container'>
<header className='header'>
<h1>🚀 Ubidots React HTML Canvas - Basic Usage</h1>
<p>Simple example showing core functionality</p>
</header>
<main>
<DeviceInfo />
</main>
</div>
</UbidotsProvider>
);
}
export default BasicUsage;