React에서 reduxtoolkit 사용해보기 .with AsyncThunk
// redux/modules/postSlice.js import { createAsyncThunk,createSlice } from "@reduxjs/toolkit"; const initialState = { // 초기값, data, isLoading, error로 상태관리 posts: [], isLoading: false, error: null, }; const postsSlice = createSlice({ name:"posts", initialState: [], reducers: { createPost: (state,action) =>{ // 액션 생성함수 state = state.concat(action.payload); // dispatch 실행부분 } } }) export const {} =..
2022. 9. 1.