我正在编写应用程序,其中逻辑存储在 redux 工具包中。你能告诉我如何将来自 getPostSuccess.state.post 的数据作为 onGetPostHandler 函数的参数传递,以便我可以在 postTitle 和 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 !