ThemeContext.Provider报错

来源:5-2 Context 编码

幕布斯1241391

2020-08-07 11:51

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>,

该怎么解决呢???

写回答 关注

1回答

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

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


基于实例的 React16 傻瓜课程

通过一系列简单有趣的例子,让你了解 React16 的基本概念和新特性

22387 学习 · 106 问题

查看课程

相似问题