Cannot read property '__reactAutoBindMap' of undefined

99封情书 提交于 2019-12-05 02:01:11

I have nearly the same problem. I had:

 React.render(AppTag(config), node);

Where AppTag was require() to JSX file. And this generate me "Cannot read property '__reactAutoBindMap' of undefined"

I try few things, but only this solved my problem:

 React.render(React.createElement(AppTag, config), node);

I hope this will be helpful

I tried more things, this also works:

 React.render(React.createFactory(AppTag)(config), node)
svnm

In react v 0.12.* you will get the following warning:

Warning: Something is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory

The link states that your code is calling your component as a plain function call, which is now deprecated

However, when you update to react v 0.13.*, this, will no longer work

You will have 2 options to upgrade:

Using JSX

React components can no longer be called directly like this. Instead you can use JSX:

var React = require('react');
var MyComponent = require('MyComponent');

function render() {
  return <MyComponent foo="bar" />;
}

Without JSX

If you don't want to, or can't use JSX, then you need to wrap your component in a factory before calling it

var React = require('react');
var MyComponent = React.createFactory(require('MyComponent'));

function render() {
  return MyComponent({ foo: 'bar' });
}

Or you can create the element inline

function render(MyComponent) {
  return React.createElement(MyComponent, { foo: 'bar' });
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!