21.07.21 Clone Coding ๐Ÿคด๐Ÿฝ๐Ÿ‘ธ๐ŸฝRedux ToolKit

729 ๋‹จ์–ด ReactTILReact

์•„๋‹ˆ ๋‚ด๊ฐ€

๋ฆฌ๋•์Šค ์ด๊ฑฐ ์ง„์งœ plz... Make me to understand 'bout Redux ๊ตฌ๊ฑธํ•˜๊ณ  ๋‹ค๋‹ˆ๋ฉด์„œ
์ดํ•ดํ•œ์ง€ ์–ผ๋งˆ๋‚˜ ๋ฌ๋‹ค๊ณ  ๋ฆฌ๋•์Šค ๋ณ€ํ˜•๋ฒ„์ „ createSlice๋ฅผ ์“ฐ๊ฒŒ๋ฌ๋‹ค ๐Ÿคท๐Ÿฝโ€โ™€๏ธ๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿฆผ

const user = createSlice({
  name: "user",
  initialState,
  reducers: {
    actionSetUser: (state, action) => {
      state.user_info = action.payload;
      state.is_login = true;
    },
    actionDelUser: (state, action) => {
      state.is_login = false;
    },
    actionChangeProfile: (state, action) => {
      state.user_info.profileUrl = action.payload;
    },
  },
});

์•ก์…˜๊ณผ ๋ฆฌ๋“€์„œ๋ฅผ ํ•œ๋ฒˆ์— ์ž‘์„ฑํ•˜๋ผ๋Š”๊ฑด๋ฐ ์ผ๋‹จ ๋ญ ๋‹ค๋“ค ์ด๊ฑฐ ์“ฐ๋Š” ํŠธ๋ Œ๋“œ๋‹ˆ๊ป˜ ์ข€ ์จ๋ณด๋ฉด์„œ ์ตํ˜€์•ผ๊ฒ ๋‹ค

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ