@fluentui/state
A set of utils to create framework agnostic and reusable state managers.
Installation
NPM
npm install --save @fluentui/state
Yarn
yarn add @fluentui/state
Usage
import { createManager, ManagerFactory } from '@fluentui/state';
type InputState = { value: string };
type InputActions = { change: (value: string) => void };
const createInputManager: ManagerFactory<InputState, InputActions> = config =>
createManager<InputState, InputActions>({
...config,
actions: {
change: (value: string) => () => ({ value })
},
state: { value: '', ...config.state }
});
const manager = createInputManager({ state: { value: 'Hello world!' } });
Usage with React
We provide React bindings under @fluentui/react-bindings
.