“Zustand Counter simples” Respostas de código

Zustand Counter simples

// 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})) 
}))
Puzzled Puffin

Zustand Counter simples

// 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})) 
}))
Puzzled Puffin

Respostas semelhantes a “Zustand Counter simples”

Perguntas semelhantes a “Zustand Counter simples”

Procure respostas de código populares por idioma

Procurar outros idiomas de código