我正在处理我的React Native应用程序,并在遇到此错误时重新加载了模拟器:
Haste模块映射中不存在模块
EmployeeFormReducer
EmployeeFormReducer
是我已经拥有的简化器,我在模拟器中对其进行测试之前就添加了EMPLOYEE_UPDATE
案例:
import { EMPLOYEE_UPDATE } from '../actions/types';
const INITIAL_STATE = {
name: '',
phone: '',
shift: ''
};
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case EMPLOYEE_UPDATE:
return { ...state, [action.payload.prop]: action.payload.value };
default:
return state;
}
};
我没有忘记将其添加到我的CombineReducers:
import { combineReducers } from 'redux';
import AuthReducer from './AuthReducer';
import EmployeeFormReducer from 'EmployeeFormReducer';
export default combineReducers({
auth: AuthReducer,
employeeForm: EmployeeFormReducer
});
我认为它是基于facebook github上已记录的React Native问题:
这可能与 https://github.com/facebook/react-native/issues/4968要解决,请尝试 下列: 1.清除值班员手表:
watchman watch-del-all
。 2.删除node_modules
文件夹:rm -rf node_modules && npm install
。 3.重置Metro Bundler缓存:rm -rf /tmp/metro-bundler-cache-*
或npm start -- --reset-cache
。 4.删除急速缓存:`rm -rf / tmp / haste-map-react-native-packager-*
但是我运行了所有这些命令,但仍然出现错误。
答案 0 :(得分:0)
在导入中,您应指定要导入文件的路径,并查看如何导入“ AuthReducer”,因此对“ EmployeeFormReducer”的导入应为:
import EmployeeFormReducer from './EmployeeFormReducer';
或文件的任何完整路径。