I have created the following store using Zustand:
import create from "zustand"
const useStore = create((set) => ({
show: false,
toggleShow: () => set((state) => ({ show: !state.show })),
}))
I assumed that this would be the correct way to toggle the value of show
. However, typescript is not happy -- it has a red squiggly line underneath the show
in !state.show
with the following error message:
Property 'show' does not exist on type 'object'.ts(2339)
any
Any idea why I am getting that error message and how I can properly set up a toggle function using Zustand?
Thanks.