// 아래는 persistReducer 코드의 일부분입니다.
export default function persistReducer<State: Object, Action: Object>(
config: PersistConfig, // 첫 번째 인자는 config
baseReducer: (State, Action) => State // 두 번째인자는 Reducer입니다.
): (State, Action) => State & PersistPartial {
//...
return (state: State, action: Action) => {
//...
// 여기서 어떤 액션이 오면 PERSIST 액션을 탐지하면 특정 기능을 수행하고 두 번째 인자로 들어온 Reducer를 반환합니다.
// 나머지 액션도 비슷합니다.
if (action.type === PERSIST) {
return {
...baseReducer(restState, action),
_persist: { version, rehydrated: false },
}
} else if (action.type === PURGE) {
//...
return {
...baseReducer(restState, action),
_persist,
}
} else if (action.type === FLUSH) {
//...
return {
...baseReducer(restState, action),
_persist,
}
} else if (action.type === PAUSE) {
//...
} else if (action.type === REHYDRATE) {
//...
}
Created
April 18, 2021 08:31
-
-
Save qkreltms/1fc50276dc73f6c2ce52816c9fff5dc0 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment