Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

前端 未结 30 1455
孤城傲影
孤城傲影 2020-11-22 06:53

I am getting this error:

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/funct

30条回答
  •  无人共我
    2020-11-22 07:40

    https://github.com/rackt/react-router/blob/e7c6f3d848e55dda11595447928e843d39bed0eb/examples/query-params/app.js#L4 Router is also one of the properties of react-router. So change your modules require code like that:

      var reactRouter = require('react-router')
      var Router = reactRouter.Router
      var Route = reactRouter.Route
      var Link = reactRouter.Link
    

    If you want to use ES6 syntax the link use(import), use babel as helper.

    BTW, to make your code works, we can add {this.props.children} in the App, like

    render() {
      return (
        

    App

    • About
    {this.props.children}
    ) }

提交回复
热议问题