// 表单属性
const fromProps = {
yangben,tanxingbi,hangqing,lazhu,kzd,
onSearch(fieldsValue) {
dispatch({
type: 'tunmo/showModal',
payload: {
modalType: 'create',
},
});
}
};
// 渲染
return (
<div>
<Layout location={location}>
<Row>
<Col span={5} className={styles.rightBorder}>
<From {...fromProps}/>
</Col>
<Col span={19} className={styles.connect}>
<ChartShape height={490}/>
</Col>
</Row>
</Layout>
</div>
);
通过一些文档了解,Effects大约是做异步处理的,Reducers是做同步处理的
这里有个疑问,什么时候用Effects,什么时候用Reducers呢?
调用方式有何不同?
修改 state 时用 Reducer,其他情况都用 Effect 。
那还请问下,调用方式有啥不同吗?
没有不同,都是通过 dispatch(Action)
effects: {
*create(){},
},
reducers: {
create(){}
}
那我这样写,dispatch(users/create) 合法?会调用那个呢?
两个都调。
@junmaqiang 建议先阅读相关文档(教程)https://github.com/dvajs/dva-docs/blob/master/v1/zh-cn/tutorial/01-%E6%A6%82%E8%A6%81.md
备注:在dva@2后,只有effect会调用,所以reducer和effect的方法不能同名。 #1186
Most helpful comment
没有不同,都是通过
dispatch(Action)