react icon indicating copy to clipboard operation
react copied to clipboard

Wire up auto-binding

Open dotfelixb opened this issue 11 years ago • 7 comments

I keep getting this error using react edge. Uncaught TypeError: Cannot read property '__reactAutoBindMap' of undefined

dotfelixb avatar Dec 04 '14 23:12 dotfelixb

If you believe this error is due to a bug in react, please post a simple example (fragment of code) that demonstrates the issue so we can reproduce/verify.

jimfb avatar Dec 05 '14 00:12 jimfb

@jsfb found out it was because of API changes. was still calling renderComponent and not using createElement.

React.renderComponent(
    div(null), document.getElementById( 'component' )
);

instead of

React.render(
    React.createElement(div,null), document.getElementById( 'component' )
);

dotfelixb avatar Dec 05 '14 12:12 dotfelixb

That still shouldn't happen. @jsfb Do you have a repro case now? It might be worth fixing and doing a point release sometime.

sophiebits avatar Dec 05 '14 14:12 sophiebits

This was apparently with edge (presumably not 0.12). I also can't reproduce so I don't think there's anything to do here. Let us know if you see it again @dotfelixb!

zpao avatar Dec 06 '14 00:12 zpao

http://jsfiddle.net/tiagorg/5L9qxnsq/ any suggestions how fix it

coyotte avatar Dec 31 '14 01:12 coyotte

@coyotte

As of React's edge version (that's what you're using in the fiddle) you can no longer use component constructors directly when building virtual DOM tree. Use React.createElement instead.

Before:

    React.renderComponent(
        BoxesView({count: counter++}),
        document.getElementById('grid')
    );

After:

    React.render(
        React.createElement(BoxesView, {count: counter++}),
        document.getElementById('grid')
    );

(or you can use JSX transform which does this for you.)

See updated fiddle.

You can also change React's version to 0.12 where previous API is deprecated but is still working.

gaearon avatar Dec 31 '14 02:12 gaearon

Same error occurs with stateless component defining. like this:

let StateLessView = (props)=> <div>{props.content}</div>;

And seems only with some environments: mine is windows 7, node 4.2.2; and node 5.x is fine.

watert avatar Apr 15 '16 10:04 watert