Answers for "zustand simple counter"

0

zustand simple counter

// store/store.js

import create from 'zustand'

export const useStore = create(set => ({
 count: 0,
 incrementCount: () => set(state => ({count: state.count + 1})),
 decrementCount: () => set(state => ({count: state.count - 1})) 
}))
Posted by: Guest on May-05-2022
0

zustand simple counter

// store/store.ts

import create from 'zustand'

interface Counter {
	count: number;
    incrementCount: () => void;
    decrementCount: () => void;
}

export const useStore = create<Counter>(set => ({
 count: 0,
 incrementCount: () => set(state => ({count: state.count + 1})),
 decrementCount: () => set(state => ({count: state.count - 1})) 
}))
Posted by: Guest on May-05-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language