Not Working with Zustand 4.4.6
import { create } from "zustand"; import zukeeper from 'zukeeper'; const useSecondGame = create(zukeeper(set) => ({ bears: 123454, increasePopulation: () => set((state) => ({ bears: state.bears + 1 })), removeAllBears: () => set({ bears: 0 }), })); window.store = useSecondGame; export { useSecondGame};
Also Tried, yet still not working
import { create, useStore } from "zustand"; import zukeeper from 'zukeeper';
const useSecondGame = useStore(zukeeper(set) => ({ bears: 123454, increasePopulation: () => set((state) => ({ bears: state.bears + 1 })), removeAllBears: () => set({ bears: 0 }), })); window.store = useSecondGame; export { useSecondGame};
Looks like you're not passing the right args into the zukeeper function @vaaiibhav, hence why VSCode is showing TSC errors about expected commas and semi-colons. You need to either move the closing parenthesis of the zukeeper() call to the end of the const declaration, or add another opening one around the set arg.
For example
const useSecondGame = useStore(zukeeper(set => ({
bears: 123454,
increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
removeAllBears: () => set({ bears: 0 }),
})));
window.store = useSecondGame;
export { useSecondGame};
Not tested the above in an IDE or anything but it should be right