Skip to content

@acoolhq/react-tiny-store


@acoolhq/react-tiny-store / makeStore

Function: makeStore()

makeStore<T>(initial): Store<T>

Defined in: store.ts:176

Create a minimal external store.

Type Parameters

T

T

Root state shape.

Parameters

initial

T

Initial state; also captured for getInitialState().

Returns

Store<T>

A Store<T> with getState, setState, replace, subscribe, and getInitialState.

Example

ts
const store = makeStore({ count: 0 });
store.setState(p => ({ ...p, count: p.count + 1 }));