Statekit - v2.0.1
    Preparing search index...

    Function createStore

    • Creates a store with an initial state and actions that can modify the state.

      Type Parameters

      • TState extends object
      • TActions extends object = Record<never, never>

      Parameters

      • initialState: TState

        The initial state of the store.

      • OptionaldefineActions: null | DefineActions<TState, TActions> = null

        A function that defines actions that can modify the state.

      • Optionaloptions: StoreOptions<TState> = {}

        Additional options for the store.

      Returns Store<TState, TActions>

      The created store with state management methods.

      import { createStore } from "@fransek/statekit";

      const store = createStore({ count: 0 }, (set) => ({
      increment: () => set((state) => ({ count: state.count + 1 })),
      decrement: () => set((state) => ({ count: state.count - 1 })),
      reset: () => set({ count: 0 }),
      }));