Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 845 Bytes

File metadata and controls

41 lines (30 loc) · 845 Bytes

React

createStateContainerReactHelpers factory allows you to easily use state containers with React.

Example

import { createStateContainer, createStateContainerReactHelpers } from 'src/plugins/opensearch_dashboards_utils';

const container = createStateContainer({});
export const {
  Provider,
  Consumer,
  context,
  useContainer,
  useState,
  useTransitions,
  useSelector,
  connect,
} = createStateContainerReactHelpers<typeof container>();

Wrap your app with <Provider>.

<Provider value={container}>
  <MyApplication />
</Provider>

Reference