Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active November 8, 2024 21:52
Show Gist options
  • Save Klerith/060281f76f3b7f0a458e4b83b1fc0062 to your computer and use it in GitHub Desktop.
Save Klerith/060281f76f3b7f0a458e4b83b1fc0062 to your computer and use it in GitHub Desktop.
Cascaron para crear Redux Slices rápidamente
import { createSlice } from '@reduxjs/toolkit';
export const templateSlice = createSlice({
name: 'name',
initialState: {
counter: 10
},
reducers: {
increment: (state, /* action */ ) => {
//! https://react-redux.js.org/tutorials/quick-start
// Redux Toolkit allows us to write "mutating" logic in reducers. It
// doesn't actually mutate the state because it uses the Immer library,
// which detects changes to a "draft state" and produces a brand new
// immutable state based off those changes
state.counter += 1;
},
}
});
// Action creators are generated for each case reducer function
export const { increment } = templateSlice.actions;
@LucianoChilean
Copy link

Gracias !!!!

@sebassg7
Copy link

Gracias por esta pieza de código Fernando, un abrazo!!!

@AbrahamVasquez
Copy link

Hay algo que este hombre no haga bien? ☑️☑️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment