How CreateStore In Zustand Works
Zustand's createStore explained: an arrow function that accepts createState, initializing state with setState, getState & api
In this article, we will understand how createStore in Zustand’s source code is written/works.
createStore is exported from vanilla.ts and you will find this at the end of the file.
export const createStore = ((createState) =>
createState ? createStoreImpl(createState) : createStoreImpl) as CreateStore
createStore is arrow function that accepts a parameter called createState. if createState exists, createStoreImpl(createState) is called.
createStoreImpl
const createStoreImpl: CreateStoreImpl = (createState) => {
type TState = ReturnType<typeof createS...