【问题标题】:React Context not running in CodeSandBoxReact Context 未在 CodeSandBox 中运行
【发布时间】:2018-09-09 16:29:36
【问题描述】:

我正在尝试在代码沙箱中运行 this React Context example,但收到此错误:

Invariant Violation

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Check the render method of `MyProvider`.

我将 React 设置为 16.3,并且代码本身是直接从 this Wes Bos example. 提取的。我已经查看了几次代码,但没有发现任何问题。这可能是我不理解的带有代码框的上下文设置吗?

【问题讨论】:

    标签: reactjs codesandbox


    【解决方案1】:

    您还必须使用 16.3 版本的 react-dom。在您的沙箱中,react 是 16.3.0,react-dom 是 16.2.0。这是一个带有工作示例的沙箱:https://codesandbox.io/s/1r1j221nl3

    【讨论】:

      猜你喜欢
      • 2020-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      相关资源
      最近更新 更多