Last active
May 25, 2024 13:34
-
-
Save astrarudra/66ce6f5b3569965be622a4b0e8fd1124 to your computer and use it in GitHub Desktop.
zustand-controller - Setup Store
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createWithEqualityFn } | |
from 'zustand/traditional' | |
import { immer } from 'zustand/middleware/immer' | |
import { shallow } from 'zustand/shallow' | |
/* I named it OxyStore - Using | |
createWithEqualityFn for Default Equality fn. */ | |
const useOxyStore = createWithEqualityFn( | |
immer(// Immutable State & no return required. | |
(...o) => ({ | |
...generalSlice(...o), | |
...notificationSlice(...o), | |
}) // Split into slices for extensibility. | |
) | |
) | |
, shallow) // 2nd param of createWithEqualityFn. | |
export useOxyStore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment