问答详情
源自:5-2 Context 编码

ThemeContext.Provider报错

ThemeContext.Provider一加,就报错

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of `App`.

Module../src/index.js

C:/Learning/react1010806/src/index.js:8

   5 | import * as serviceWorker from './serviceWorker';
  6 | import 'bootstrap/dist/css/bootstrap.min.css';
  7 |
>  8 | ReactDOM.render(
  9 |   <React.StrictMode>
 10 |     <App />
 11 |   </React.StrictMode>,

该怎么解决呢???

提问者:幕布斯1241391 2020-08-07 11:51

个回答

  • allonn
    2020-10-17 18:49:25

    确认是否导入:import ThemeContext from './theme-context'