【发布时间】:2018-09-11 08:43:35
【问题描述】:
我有一个关于 React Native 中的 reducer 的简短问题
为什么一定要这样写代码:
import { combineReducers } from 'redux';
export default combineReducers({
reducerKey : () => []
});
而不是这个:
import { combineReducers } from 'redux';
export default combineReducers({
reducerKey : []
});
基本上:为什么它必须是一个函数? 谢谢!
【问题讨论】:
-
没有必要。您可以使用第二个版本,大多数人更喜欢这个
-
reducer 是一个返回值的函数。如果您不想要函数,只需输入您想要的值即可。
-
实际上我尝试了第二个,但是没有用(react-native)
标签: javascript reactjs react-native redux