Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.refs sometimes equals to null #22

Closed
fritx opened this issue Jan 8, 2016 · 4 comments
Closed

this.refs sometimes equals to null #22

fritx opened this issue Jan 8, 2016 · 4 comments

Comments

@fritx
Copy link

fritx commented Jan 8, 2016

  render() {
    return (
      <img className="avatar-one" ref="img"
        onLoad={()=>{
          console.log('onload this.refs', this.refs)
        }}
        onError={()=>{
          console.log('onerror this.refs', this.refs)
        }} />
    )
  }

Hey @Lucifier129
In react-lite, I found that this.refs sometimes equals to null, called in onLoad/onError of <img> tag.
The probability is very small, but I can always reproduce it by very frequent rendering.
It causes a bug in my app.
And when I try the regular React, it's fine.

@Lucifier129
Copy link
Owner

I got the problem and try to fixed it in version 0.0.16.

Even the element has been removed, onload/onerror would still be triggered. react-lite will removeEvent all the event handler in its props at v0.0.16.

please update react-lite, and try again.

@Lucifier129
Copy link
Owner

sorry about misunderstand your description.

I had try many time about onload/onerror, and can't reappear this.refs == null.

I wonder which browser did you use. (since I tryed it at chrome), maybe other browser's onload/onerror event would be triggered, even the element did'nt insert to document but already in memory.

You can add debugger when onload event is calling, and check whether the img elment was inserted to document or not.

@fritx
Copy link
Author

fritx commented Jan 11, 2016

But it seems that the problem was gone after upgrading react-lite last week.

@Lucifier129
Copy link
Owner

OK:-)

Now which version of react-lite are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants