Redux를 사용하여 내 앱 상태를 관리하고 redux-thunk
으로 비동기 작업을 수행했습니다.디스패치없이 redux-thunk 작업 실행
export const login = credentials => dispatch => {
return doLogin(credentials).then(token => {
localStorage.setItem('token', token)
// this dispatch call was there before, but now it has gone,
// because it is not necessary anymore
// dispatch({ type: LOGIN_SUCCESS })
})
}
이제는 작업을 저장소로 보내지 않으며, 로그인 및 저장 토큰에 대한 작업 만 수행합니다.
그런 종류의 행동을해도 괜찮습니까? 나는이 코드에 대해 매우 확신하지는 않지만 그것을 더 잘 만드는 방법을 모른다.
이 기능은 상태로 전혀 수행하지 않습니까? –