我有一个传奇观察者,比如:
export default function * root () {
yield all([
takeLatest(HoraBusaoTypes.GET_HORA_BUSAO, getHorasBusao)
])
}
所以我
put
在这个传奇故事中,redux存储的数据如下:
export function * getHorasBusao(action) {
yield put({ type: HoraBusaoTypes.TEST, nome: 'New York' });
}
我有一个减速器(我正在使用
reduxsauce
):
export const test = (state, action) => {
const { nome } = action;
return { ...state, nome };
};
export const reducer = createReducer(INITIAL_STATE, {
[Types.TEST]: test
})
因此,我将在
componentDidMount
:
componentDidMount() {
this.props.getHoras('Any city')
}
// -------------------------------------------------------------------
// redux map
function mapStateToProps(state) {
const { horaBusao } = state;
return {
nome: horaBusao.nome
}
}
function mapDispatchToProps(dispatch) {
return {
getHoras: (city) => dispatch({ type: 'GET_HORA_BUSAO', city })
}
}
但它没有在页面上显示数据,所以我添加了一个
console.warn
进入
render
功能,我发现数据已经被设置和重置:
代码的哪一部分正在重置我的redux存储?