How to type set action without setXXX ? #2599
Answered
by
dai-shi
vaynevayne
asked this question in
Q&A
-
type Actions = {
set: () => void // ???
reset: () => void
}
const useLocalStore = create<State & Actions>()(
persist(
(set, get) => ({
...initialState,
set,
reset: () => {
set(initialState)
},
}),
{
name: 'log-storage',
storage: createJSONStorage(() => localStorage),
},
),
) |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Jun 13, 2024
Replies: 1 comment 3 replies
-
It depends on how much api you want to expose, but for example this works: https://tsplay.dev/Nnj2vN |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
vaynevayne
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It depends on how much api you want to expose, but for example this works: https://tsplay.dev/Nnj2vN