Getting “Cannot call a class as a function” in my React Project

后端 未结 30 1021
無奈伤痛
無奈伤痛 2020-12-07 16:34

I\'m trying to add a React map component to my project but run into an error. I\'m using Fullstack React\'s blog post as a reference. I tracked down where the error gets thr

30条回答
  •  渐次进展
    2020-12-07 16:43

    I have also run into this, it is possible you have a javascript error inside of your react component. Make sure if you are using a dependency you are using the new operator on the class to instantiate the new instance. Error will throw if

    this.classInstance = Class({})

    instead use

    this.classInstance = new Class({})

    you will see in the error chain in the browser

    at ReactCompositeComponentWrapper._constructComponentWithoutOwner

    that is the giveaway I believe.

提交回复
热议问题