Demo on how to leverage useCurrentViewState hook
useCurrentViewState hook
import { useCurrentViewState } from '@adaptabletools/adaptable-infinite-react';
You can use this hook in any component rendered inside the <Adaptable.Provider />
component.
It gives you access to the state of the currently active view.
This example shows how to leverage useCurrentViewState
to access the current view from different places of your app.
Change the view to see the UI and the column header update.
Usage
import { useCurrentViewState } from '@adaptabletools/adaptable-infinite-react';
const view = useCurrentViewState();
import { Adaptable, useCurrentViewState } from '@adaptabletools/adaptable-infinite-react';
function Welcome() {
const view = useCurrentViewState();
return <div>Curent View: {view?.label ?? 'None'}</div>;
}
export default function App() {
return (
<Adaptable.Provider
data={rowData}
primaryKey="id"
adaptableId={`use-current-view-state-demo`}
licenseKey={'...'}
defaultState={state}
>
<Welcome />
<Adaptable.UI />
</Adaptable.Provider>
);
}