@fluentui/state

A set of utils to create framework agnostic and reusable state managers

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@fluentui/state
17,6816490.66.510 months ago4 years agoMinified + gzip package size for @fluentui/state in KB

Readme

@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.