1
redux
스토어에 이미 연결되어 있고 dispatch
이 삽입 된 구성 요소가 있습니다. 이 같은 withReducer
및 withHandlers
사용하여 구성 요소의 로컬 상태를 업데이트하려고 : 내가 찾을withHedlers의 withReducer에서 재구성 된 로컬 디스패치 기능
const reducer = (state, action) => {
switch (action.type) {
case 'SET_ACTIVE_TAB':
console.log('recieved action', action)
const { activeTab } = action
return activeTab
default:
return state
}
}
const initialState = 'actions'
const handlers = withHandlers({
onTabClick: props => (e, { name }) => {
const { dispatchLocal } = props
dispatchLocal({
type: 'SET_ACTIVE_TAB',
activeTab: name
})
}
})
const enhancer = withReducer('activeTab', 'dispatchLocal', reducer, initialState)
을 그 때 compose
:
compose(handlers, enhancer)(LayerListItem)
dispatchLocal
소품 handler
내에 정의되지 않았습니다. recompose
으로 작업 작성자를 만들고 바인딩하는 가장 좋은 방법은 응용 프로그램 상태를 업데이트하는 것입니다.