withDashboard
A higher-order component that initializes the Wix React SDK and the Wix Dashboard SDK.
Wrap your topmost component with withDashboard()
. This setup ensures that nested components can use hooks like useWixModules()
and useDashboard()
and that the dashboard's contextual state is passed to all child components.
Note:
When you wrap a component with withDashboard()
, a WixProvider
component is initialized behind the scenes with the dashboard host and authentication strategy.
Signature
1
Parameters
Name | Type | Description |
---|---|---|
Component | React.ComponentType<P> | A React component. |
Returns
React.ComponentType<unknown>
Examples
To set up a dashboard client for React, refer to the setup guide.
Wrap a component
Here is a basic example of how to wrap a component using withDashboard
.
1
Receive contextual state
This example shows how to retrieve a property called name
from the dashboard's contextual state and use it in a component's code.
1