Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active August 19, 2025 17:07
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.

Revisions

  1. Klerith revised this gist May 13, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions templateSlice.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    import { createSlice } from '@reduxjs/toolkit';

    export const templaceSlice = createSlice({
    export const templateSlice = createSlice({
    name: 'name',
    initialState: {
    counter: 10
    @@ -19,5 +19,5 @@ export const templaceSlice = createSlice({


    // Action creators are generated for each case reducer function
    export const { increment } = templaceSlice.actions;
    export const { increment } = templateSlice.actions;

  2. Klerith created this gist May 13, 2022.
    23 changes: 23 additions & 0 deletions templateSlice.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import { createSlice } from '@reduxjs/toolkit';

    export const templaceSlice = 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 } = templaceSlice.actions;