Sentre
Search…
Providers
The series of context providers
By these context providers, a DApp can easily access data that is provided by the os. The context is pretty diverse including user interface info, wallet info, blockchain data, etc.
To use a provider, you need to wrap your DApps by the provider. For example, to access the user interface info like current viewpoint, is-touchable, etc., I have to wrap the widget view into the UI Provider.
1
// widget.app.tsx
2
// ...
3
const Widget = () => {
4
return (
5
<UIProvider appId={appId}>
6
<Provider store={model}>
7
<WidgetView />
8
</Provider>
9
</UIProvider>
10
)
11
}
12
// ...
Copied!
Then all components inside the widget view can read the user interface info like this,
1
// widget/index.tsx
2
// ...
3
import { useUI } from 'senhub/providers'
4
5
const Widget = () => {
6
const {
7
ui: { width, infix },
8
} = useUI()
9
}
10
// ...
Copied!
Copy link