This commit is contained in:
javad committed 2023-10-14 11:08:42 +03:30
1 parent c39ef2621c
commit b27f4f2f23
25 files changed
+970 -294

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
'use client'
import { createSlice } from "@reduxjs/toolkit"
interface CounterState {
counter_value: number
}
const initialState: CounterState = {
counter_value: 0
}
export const counterSlice = createSlice({
name: 'counter',
initialState,
reducers: {
incr: (state)=>{
state.counter_value += 1
},
decr: (state)=>{
state.counter_value -= 1
},
},
})
export const { incr, decr } = counterSlice.actions;
export default counterSlice.reducer;
+14
View File
@@ -0,0 +1,14 @@
'use client'
import { Provider } from "react-redux"
import { store } from "./store"
const ReduxProvider = ({children} : {children: React.ReactNode})=>{
return (
<Provider store={store}>
{ children }
</Provider>
)
}
export default ReduxProvider
+15
View File
@@ -0,0 +1,15 @@
'use client'
import { configureStore } from "@reduxjs/toolkit"
import couterReducer from "./features/couterSlice"
export const store = configureStore({
reducer: {
counter: couterReducer
},
})
export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch