StoreType

Interface representing the data structure of any zfy store's getState()output.

src/types.ts
import type { State } from 'zustand'

interface StoreType<StoreDataType> extends State {
  name: string
  data: StoreDataType
  reset: () => void
  update: (producer: (data: StoreDataType) => void) => void
}
Unexpected error with integration github-files: Integration is not authenticated with GitHub

API reference

name

Name of the store to create.

data

Data you want to save in your store. Can be of any type. As the zustand doc states:

You can put anything in it: primitives, objects, functions.

reset

Function that, once invoked, resets the store's data to the value of the initialData provided to createStore()'s 2nd argument.

update

Function that allows you to update your data. The current value is provided to the producer function and thanks to Immer: you don't have to care about immutability at all. Example:

Last updated

Was this helpful?