2
3

More than 5 years have passed since last update.

Reactを0.13系にあげたら"Cannot read property '__reactAutoBindMap' of undefined"でコケた

Last updated at Posted at 2015-04-23

Reactのv0.13でいろいろ変更があったようで、バージョンを上げたら"Cannot read property '__reactAutoBindMap' of undefined"エラーが発生するようになってしまいました。  

createElementでComponentを包んであげるとエラーが消えました。

Server-side renderingをしています。

app.js

var APP = React.createClass({
  render: function() {
    return (
      <html>
        <head>
          <title>React Server-Side Rendering</title>
        </head>
        <body>
          <SampleComponent />
          <script src='public/bundle.js'></script>
        </body>
      </html>
    );
  }
});

module.exports = APP;

if(typeof window !== 'undefined') {
  window.onload = function() {

    //for previous versions
    //React.render(APP(), document);

    //for version "^0.13.0"
    React.render(React.createElement(APP, {}), document);
  }
};

server.js
app.get('/', function(req, res) {

  //for previous versions
  //var markup = React.renderToString(APP());

  //for version "^0.13.0"
  var markup = React.renderToString(React.createElement(APP,{}));

  res.send(markup);
});

参考: https://github.com/facebook/react/issues/2661

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3