该代码以前曾经运行过,但是现在我遇到了“钩子规则”错误。
我想念什么?
import React, { createContext, useReducer } from 'react';
import initialState from './initialState';
import reducer from './reducer';
import actions from './actions';
const uiContext = createContext();
const uiProvider = ({ children }) => {
const [state, dispatch] = useReducer(reducer, initialState);
return (
<uiContext.Provider
value={{ state, actions: actions(dispatch) }}
children={children}
/>
);
};
export { uiContext, uiProvider };
答案 0 :(得分:0)
Danko的上述评论解决了这个问题。首先用大写字母解决了这个问题,谢谢!