redux 저장소가 변경된 후에 연결된 구성 요소가 다시 렌더링되지 않습니다.연결 저장 구성 요소가 변경된 후에 연결 구성 요소가 다시 렌더링되지 않습니다.
가게 구조 :
{
user: {
profile: {
email: null
}
}
}
내가 UPDATE 동작 작성자 파견하고 있습니다 :
매장 상태를 업데이트dispatch(profile.actions.update({email: '[email protected]'}));
하지만 이 연결된 ProfilePage 구성 요소를 다시 렌더링하지 않습니다 !
-
/ProfilePage.js (접속 부품)
//component omitted
function mapStateToProps(state) {
return {
initialFormValues: state.user.profile
}
}
export default connect(mapStateToProps)(ProfilePage)
/profileReducer.js (업데이트 작업이 인터셉트)
export default function(state = { email: null }, action) {
switch (action.type) {
case t.UPDATE:
return { ...state, ...action.values }; //this is a new object (not mutated)
default:
return state;
};
};
/userReducer.js
import { combineReducers } from 'redux';
import session from './session';
import profile from './profile';
export default combineReducers({
profile: profile.reducer
});
/rootReducer.js
import {combineReducers} from 'redux';
import {routerReducer as router} from 'react-router-redux';
import { reducer as form } from 'redux-form';
import user from './modules/user';
const rootReducer = combineReducers({
form,
user: user.reducer,
router
})
export default rootReducer;
/store.js
import reducer from './rootReducer';
import thunk from 'redux-thunk'
import logger from 'redux-logger'
import { createStore, compose, applyMiddleware } from 'redux';
import { routerMiddleware as router } from 'react-router-redux';
export default function(history) {
return createStore(
reducer,
compose(
applyMiddleware(
router(history),
thunk,
logger
)
)
)
}
내 생각 엔 내 이해에서 –