Redux Slice erstllen für Chart Data
This commit is contained in:
25
redux/slices/chartDataSlice.ts
Normal file
25
redux/slices/chartDataSlice.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface ChartDataState {
|
||||
data: any[];
|
||||
}
|
||||
|
||||
const initialState: ChartDataState = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
export const chartDataSlice = createSlice({
|
||||
name: "chartData",
|
||||
initialState,
|
||||
reducers: {
|
||||
setChartData: (state, action: PayloadAction<any[]>) => {
|
||||
state.data = action.payload;
|
||||
},
|
||||
clearChartData: (state) => {
|
||||
state.data = [];
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setChartData, clearChartData } = chartDataSlice.actions;
|
||||
export default chartDataSlice.reducer;
|
||||
@@ -2,11 +2,13 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import authReducer from "./slices/authSlice";
|
||||
import variablesReducer from "./slices/variablesSlice";
|
||||
import chartDataReducer from "./slices/chartDataSlice";
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
auth: authReducer,
|
||||
variables: variablesReducer,
|
||||
chartData: chartDataReducer,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user