在这段代码中,流程并没有抱怨在状态上设置的值狗.它似乎忽略了NamespaceData定义.我已经设置了类型,所以它应该抱怨.我正在使用核素,流量正在为其他一切正常运行.
命名空间,项目,集合等所有动作属性都是字符串.
// @flow import { NAMESPACE_SET } from '../actions/NamespaceActions' type NamespaceData = { project: string,collection: string,} type NamespaceState = { [namespace: string]: NamespaceData,} const initialState: NamespaceState = {} function namespaceReducer(state: NamespaceState = initialState,action: Object): NamespaceState { switch (action) { case NAMESPACE_SET: { return { ...state,[action.namespace]: { project: action.project,collection: action.collection,dog: 1,} } } } return state } export default namespaceReducer