“Zustand Simple Counter” Código de respuesta

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

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

Respuestas similares a “Zustand Simple Counter”

Preguntas similares a “Zustand Simple Counter”

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código