Plugin
createPluginStore
It returns a new instance of PluginStore.
Arguments: (void
)
Returns: (PluginStore
)
const pluginStore = createPluginStore();
PluginProvider
The
Props
value
(PluginStore): The single PluginStore of your application.children
(ReactElement): The root of your component hierarchy.
Example:
const pluginStore = createPluginStore();
function App() {
return (
<PluginProvider pluginStore={pluginStore}>
<Test />
</PluginProvider>
);
}
usePluginStore
It is used to get the instance of PluginStore in the components which are nested in PluginProvider.
const pluginStore: any = usePluginStore();
Example:
Here, we are retrieving the instance of PluginStore and calling the sendAlert function contained in the store.
const Test = (props: any) => {
const pluginStore: any = usePluginStore();
return (
<>
<h1>Working</h1>
<button
onClick={() => {
pluginStore.executeFunction("showAlert");
}}
>
Send Alert
</button>
</>
);
};