I'm writing app where logic is stored in redux toolkit. Can You please tell me how can I pass data from getPostSuccess.state.post as argument of the function onGetPostHandler so I can use it in postTitle and postBody
export const postSlice = createSlice({
name: "post",
initialState: initialPostState,
reducers: {
getPost: (state) => {
state.loading = true;
},
getPostSuccess: (state, { payload }) => {
state.post = payload;
state.loading = false;
state.hasErrors = false;
},
getPostFailure: (state) => {
state.loading = false;
state.hasErrors = true;
},
},
});
export const onGetPostHandler = () => {
let i = 0;
const postTitle = post[i].title;
const postBody = post[i].body;
i++;
};
thanks !