Skip to content

Conversation

PocheonLim
Copy link
Collaborator

๐Ÿ“ ๋ฏธ์…˜ ๋ฒˆํ˜ธ

9์ฃผ์ฐจ ๋ฏธ์…˜ 1, 2, 3

๐Ÿ“‹ ๊ตฌํ˜„ ์‚ฌํ•ญ

  • Redux tollkit์„ ์ด์šฉํ•œ ์žฅ๋ฐ”๊ตฌ๋‹ˆ
  • zustand๋กœ ๊ตฌํ˜„

๐Ÿ“Ž ์Šคํฌ๋ฆฐ์ƒท

bandicam.2025-05-26.14-26-03-925.mp4

โœ… ์ฒดํฌ๋ฆฌ์ŠคํŠธ

  • Merge ํ•˜๋ ค๋Š” ๋ธŒ๋žœ์น˜๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์„ค์ •๋˜์–ด ์žˆ๋‚˜์š”?
  • ๋กœ์ปฌ์—์„œ ์‹คํ–‰ํ–ˆ์„ ๋•Œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋‚˜์š”?
  • ๋ถˆํ•„์š”ํ•œ ์ฃผ์„์ด ์ œ๊ฑฐ๋˜์—ˆ๋‚˜์š”?
  • ์ฝ”๋“œ ์Šคํƒ€์ผ์ด ์ผ๊ด€์ ์ธ๊ฐ€์š”?

๐Ÿค” ์งˆ๋ฌธ ์‚ฌํ•ญ

Copy link
Member

@hyesngy hyesngy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ •๋ง ๊ณ ์ƒ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค! ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป

์ด๋ฒˆ ์ฃผ ์›Œํฌ๋ถ์„ ํ†ตํ•ด Redux Toolkit๊ณผ Zustand ๋‘ ๊ฐ€์ง€ ์ƒํƒœ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋ชจ๋‘ ๋‹ค๋ค„๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์•ž์œผ๋กœ ํ”„๋กœ์ ํŠธ ๋ณต์žก๋„๋‚˜ ๊ทœ๋ชจ์— ๋”ฐ๋ผ ์ ์ ˆํ•œ ์ƒํƒœ๊ด€๋ฆฌ ๋„๊ตฌ๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ์•ˆ๋ชฉ์„ ๊ฐ–์ถ”๊ฒŒ ๋˜์…จ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค! ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป

Comment on lines +20 to +58
const initialState: CartState = {
items: cartItems,
totalAmount: cartItems.length,
totalPrice: cartItems.reduce((total, item) => total + Number(item.price), 0),
};

const cartSlice = createSlice({
name: 'cart',
initialState,
reducers: {
increaseAmount: (state, action: PayloadAction<string>) => {
const item = state.items.find(item => item.id === action.payload);
if (item) {
item.amount += 1;
cartSlice.caseReducers.calculateTotals(state);
}
},
decreaseAmount: (state, action: PayloadAction<string>) => {
const item = state.items.find(item => item.id === action.payload);
if (item && item.amount > 1) {
item.amount -= 1;
cartSlice.caseReducers.calculateTotals(state);
}
},
removeItem: (state, action: PayloadAction<string>) => {
state.items = state.items.filter(item => item.id !== action.payload);
cartSlice.caseReducers.calculateTotals(state);
},
clearCart: (state) => {
state.items = [];
state.totalAmount = 0;
state.totalPrice = 0;
},
calculateTotals: (state) => {
state.totalAmount = state.items.reduce((total, item) => total + item.amount, 0);
state.totalPrice = state.items.reduce((total, item) => total + (Number(item.price) * item.amount), 0);
}
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜„์žฌ cartSlice์—์„œ calculateTotals๋ฅผ caseReducers๋กœ ํ˜ธ์ถœํ•˜์—ฌ ๊ตฌํ˜„ํ•˜์…จ๋Š”๋ฐ, ์ด๋Š” ์ข‹์€ ์ ‘๊ทผ์ด์ง€๋งŒ initialState์—์„œ ์ดํ•ฉ ๊ณ„์‚ฐ ๋กœ์ง์ด ์ค‘๋ณต๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
initialState์—์„œ๋„ calculateTotals ๋กœ์ง์„ ์žฌ์‚ฌ์šฉํ•˜๋„๋ก ๋ฆฌํŒฉํ† ๋งํ•˜๋ฉด ์ฝ”๋“œ ์ค‘๋ณต์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ๊ณ , ๊ณ„์‚ฐ ๋กœ์ง์ด ํ•œ ๊ณณ์— ์ง‘์ค‘๋˜์–ด ์œ ์ง€๋ณด์ˆ˜์„ฑ์ด ํ–ฅ์ƒ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Comment on lines +1 to +13
import { configureStore } from '@reduxjs/toolkit';
import cartReducer from '../slice/cartSlice';
import modalReducer from '../slice/modalSlice';

export const store = configureStore({
reducer: {
cart: cartReducer,
modal: modalReducer,
},
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch; No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜„์žฌ ์žฅ๋ฐ”๊ตฌ๋‹ˆ ๋ฐ์ดํ„ฐ๊ฐ€ ์ƒˆ๋กœ๊ณ ์นจ ์‹œ ์ดˆ๊ธฐํ™”๋˜๊ณ  ์žˆ๋Š”๋ฐ, Redux Toolkit์˜ redux-persist๋‚˜ Zustand์˜ persist ๋ฏธ๋“ค์›จ์–ด๋ฅผ ์ ์šฉํ•˜์—ฌ, ์ƒˆ๋กœ๊ณ ์นจ ํ›„์—๋„ ์žฅ๋ฐ”๊ตฌ๋‹ˆ ์ƒํƒœ๊ฐ€ ์œ ์ง€๋˜๋„๋ก ๐Ÿš€Challenge ๋ฏธ์…˜์— ๋„์ „ํ•ด ๋ณด์‹œ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค!

Comment on lines +17 to +19
React.useEffect(() => {
calculateTotals();
}, [items, calculateTotals]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜„์žฌ useCartStore์—์„œ ๊ฐ ์•ก์…˜ ํ•จ์ˆ˜๋“ค์ด calculateTotals๋ฅผ ์ž๋™์œผ๋กœ ํ˜ธ์ถœํ•˜์ง€ ์•Š์•„ CartPage์—์„œ useEffect๋ฅผ ํ†ตํ•ด ์ˆ˜๋™์œผ๋กœ ์ดํ•ฉ์„ ๊ณ„์‚ฐํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” ์ƒํƒœ ์—…๋ฐ์ดํŠธ์™€ ์ดํ•ฉ ๊ณ„์‚ฐ์ด ๋ถ„๋ฆฌ๋˜์–ด ์ผ๊ด€์„ฑ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ, increaseAmount, decreaseAmount, removeItem, clearCart์•ก์…˜๋“ค์ด ์‹คํ–‰๋  ๋•Œ๋งˆ๋‹ค ์ž๋™์œผ๋กœ calculateTotals๋ฅผ ํ˜ธ์ถœํ•˜๋„๋ก ์ˆ˜์ •ํ•˜๋ฉด ๋”์šฑ ์•ˆ์ •์ ์ธ ์ƒํƒœ ๊ด€๋ฆฌ๊ฐ€ ๊ฐ€๋Šฅํ•  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Copy link
Member

@hyesngy hyesngy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10์ฃผ์ฐจ ์›Œํฌ๋ถ๊นŒ์ง€ ์ •๋ง ๊ธด ์—ฌ์ •์ด์—ˆ์Šต๋‹ˆ๋‹ค.
๊ทธ๋™์•ˆ ๋ชจ๋‘ ๊ณ ์ƒ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค! ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป ์งง์ง€ ์•Š์€ ๊ธฐ๊ฐ„๋™์•ˆ ์˜๋ฏธ ์žˆ๋Š” ์‹œ๊ฐ„์ด ๋˜์—ˆ๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค.

์ด์ œ ๊ธฐ๋ณธ ์›Œํฌ๋ถ์€ ๋ชจ๋‘ ์™„์ฃผํ•˜์…จ์ง€๋งŒ, 11-12์ฃผ์ฐจ ์›Œํฌ๋ถ๋„ ๋„์ „ํ•ด๋ณด์‹œ๊ธธ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค! 11์ฃผ์ฐจ์—์„œ๋Š” Vercel์„ ํ™œ์šฉํ•œ ๋ฐฐํฌ์™€ CI/CD ๊ตฌ์„ฑ์„ ๋‹ค๋ฃจ๊ณ , 12์ฃผ์ฐจ์—์„œ๋Š” WebSocket์„ ์ด์šฉํ•œ ์‹ค์‹œ๊ฐ„ ํ†ต์‹ ๊ณผ Cypress๋ฅผ ํ™œ์šฉํ•œ E2E ํ…Œ์ŠคํŠธ๋ฅผ ๋‹ค๋ฃน๋‹ˆ๋‹ค.

์•ž์œผ๋กœ๋„ ๊พธ์ค€ํžˆ ํ•™์Šตํ•˜๊ณ  ์„ฑ์žฅํ•˜์‹œ๊ธธ ์‘์›ํ•˜๋ฉฐ, ๋ฐ๋ชจ๋ฐ์ด๊นŒ์ง€ ํ™”์ดํŒ… ์ž…๋‹ˆ๋‹ค! ๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป๐Ÿ‘๐Ÿป

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜„์žฌ ์ปดํฌ๋„ŒํŠธ๋“ค์ด ์ ์ ˆํžˆ ๋ถ„๋ฆฌ๋˜์–ด ์žฌ์‚ฌ์šฉ์„ฑ์ด ์ข‹๊ฒŒ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ MovieFilter, Input, SelectBox, LanguageSelector ๋“ฑ์˜ ์„ธ๋ถ„ํ™”๋œ ์ปดํฌ๋„ŒํŠธ ๋ถ„๋ฆฌ๊ฐ€ ์ธ์ƒ์ ์ž…๋‹ˆ๋‹ค!

Comment on lines +1 to +14
import HomePage from "./pages/HomePage"
import MovieModal from "./components/MovieModal"

function App() {

return (
<>
<HomePage />
<MovieModal />
</>
)
}

export default App
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜„์žฌ App.tsx์—์„œ MovieModal์„ ์ตœ์ƒ์œ„์—์„œ ํ•ญ์ƒ ๋ Œ๋”๋งํ•˜๊ณ  ์žˆ๋Š”๋ฐ, ์ด๋Š” ๋ชจ๋‹ฌ์ด ๋‹ซํ˜€์žˆ์„ ๋•Œ๋„ DOM์— ์กด์žฌํ•˜๋ฉฐ ๋ถˆํ•„์š”ํ•œ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋น„ํšจ์œจ์ ์ž…๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, {isOpen && <MovieModal />} ํ˜•ํƒœ๋กœ ์กฐ๊ฑด๋ถ€ ๋ Œ๋”๋งํ•˜๋ฉด, ์‹ค์ œ๋กœ ๋ชจ๋‹ฌ์ด ์—ด๋ ค์žˆ์„ ๋•Œ๋งŒ ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋งˆ์šดํŠธ๋˜์–ด ์„ฑ๋Šฅ์ด ๋” ๊ฐœ์„ ๋  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

๋˜๋Š”, ๋‹จ์ผ ์ฑ…์ž„ ์›์น™์— ๋”ฐ๋ผ ๋ชจ๋‹ฌ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ณณ์—์„œ ์ง์ ‘ ๋ชจ๋‹ฌ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ๋„ ๊ณ ๋ คํ•ด๋ณผ ์ˆ˜ ์žˆ๊ฒ ์Šต๋‹ˆ๋‹ค.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants