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

onHover is broken when passing custom react element symbols #72

Closed
darkowic opened this issue Jan 5, 2018 · 4 comments
Closed

onHover is broken when passing custom react element symbols #72

darkowic opened this issue Jan 5, 2018 · 4 comments

Comments

@darkowic
Copy link
Contributor

darkowic commented Jan 5, 2018

Here is example for reproduce:
https://codesandbox.io/s/oj7mzzww36

I debug it... Problem is that RatingAPILayer PureComponent shouldComponentUpdate does not handle checking for react element. So, on every onHover execution, RatingAPILayer will be rerendered which cause multiple rerendering. Another problem is in Rating component componentWillReceiveProps:

  componentWillReceiveProps(nextProps) {
    this.setState({
      dirty: this.props.value !== nextProps.value && !this.state.dirty
        ? true
        : this.state.dirty,
      displayValue: nextProps.value
    });
  }

I do not understand why on every props update displayValue is set to nextProps.value. But if shouldComponentUpdate is handled properly in RatingAPILayer this is not a problem.

@darkowic
Copy link
Contributor Author

darkowic commented Jan 5, 2018

I'm going to fix it for you :)

@darkowic
Copy link
Contributor Author

darkowic commented Jan 5, 2018

Fixed in #73. The examples index.html is so difficult to edit or adjust :) Would be great if we rewrite it to React

@bslinger
Copy link
Contributor

bslinger commented Jan 8, 2018

I was about to make this same pull request, thanks @darkowic !

@dreyescat
Copy link
Owner

The examples index.html is so difficult to edit or adjust :) Would be great if we rewrite it to React

@darkowic Oh yes!! It would be great. I have been lazy to change the index page for a loooong time. In the beginning it was created without jsx. Then I just added the browser version of Babel just to make it easier. Even included prism to show the code that generated those ratings. But, I completely agree with you, that it is really painful to modify and add elements. Any proposal? Long time ago I read something about StoryBook but I don't know if it will fit.

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

3 participants