UNPKG

easy-peasy

Version:

Vegetarian friendly state for React

25 lines (19 loc) 423 B
/* eslint-disable */ import { action, Action, createStore } from 'easy-peasy'; interface IAnimal { name: string; age?: number; } interface IModel { animal: IAnimal; setAnimal: Action<IModel, { animal: IAnimal }>; } const model: IModel = { animal: { name: 'robert', }, setAnimal: action((state, payload) => { return { ...state, animal: payload.animal }; }), }; const store = createStore(model);