피드백 환영합니다
Redux app really only has one reducer function: the "root reducer" function that you will pass to createStore later on. That one root reducer function is responsible for handling all of the actions that are dispatched, and calculating what the entire new state result should be every time.
source: https://redux.js.org/tutorials/fundamentals/part-3-state-actions-reducers#writing-reducers
===
operator로 reference 비교를 하기 때문에 주의해야 할 사항이 있음. 아래 참조import React from 'react'
import { useSelector } from 'react-redux'
export const CounterComponent = () => {
const counter = useSelector(state => state.counter)
return <div>{counter}</div>
}
===
operator로 비교했을 때 true
일 것이므로, 리렌더링 되지 않음.import React from 'react'
import { useSelector } from 'react-redux'
export const CounterComponent = () => {
const {counter} = useSelector(state => ({counter : state.counter}))
return <div>{counter}</div>
}
===
operator로 비교했을 때 false
일 것이므로 state.counter가 변경되지 않았다고 할지라도 리렌더링을 유발함https://react-redux.js.org/next/api/hooks#performance
idiomatic-redux-thoughts-on-thunks-sagas-abstraction-and-reusability
React batched update 그리고 react-redux
dispatch & actual render relations