Dashboard runtime library
Overview
Getting started
Add the library to your project
pnpm add @ubidots/react-html-canvasyarn add @ubidots/react-html-canvasPeer Dependencies
Usage
import
UbidotsProvider,
useUbidotsReady,
useUbidotsSelectedDevice,
useUbidotsActions,
} from '@ubidots/react-html-canvas';
function DeviceInfo() {
const ready = useUbidotsReady();
const device = useUbidotsSelectedDevice();
const { setDashboardDevice } = useUbidotsActions();
if (!ready) return <span>Loading...</span>;
return (
<div>
<pre>{JSON.stringify(device, null, 2)}</pre>
<button onClick={() => setDashboardDevice('device-id')}>
Select Device
</button>
</div>
);
}
export default function App() {
return (
<UbidotsProvider readyEvents={['receivedToken']}>
<DeviceInfo />
</UbidotsProvider>
);
}API & examples
Last updated
Was this helpful?