UNPKG

@selemondev/create-react-next

Version:

The Next Generation React Scaffolding Tool ✨

27 lines (22 loc) 564 B
import { createSlice } from '@reduxjs/toolkit' const initialState = { value: 0, } export const counterSlice = createSlice({ name: 'counter', initialState, reducers: { increment: (state) => { state.value += 1 }, decrement: (state) => { state.value -= 1 }, incrementByAmount: (state, action) => { state.value += action.payload }, }, }) export const { increment, decrement, incrementByAmount } = counterSlice.actions export const selectCount = (state) => state.counter.value export default counterSlice.reducer