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

Warn if style value is NaN #5773

Closed
jimfb opened this issue Jan 4, 2016 · 4 comments
Closed

Warn if style value is NaN #5773

jimfb opened this issue Jan 4, 2016 · 4 comments

Comments

@jimfb
Copy link
Contributor

jimfb commented Jan 4, 2016

Passing a value of NaN as the value of a css style seems to indicate an error. Turns out that we don't warn on initial render, and give a confusing error on update (because NaN != NaN as per spec). Discovered in #4877 (comment)

ReactDOM.render(<div style={{marginLeft: NaN}} />, document.getElementById('container'));
ReactDOM.render(<div style={{marginLeft: NaN}} />, document.getElementById('container'));

Anyway, we should probably warn if someone passes in NaN on initial render, and not warn on update if both previous/next values are NaN.

@zpao
Copy link
Member

zpao commented Jan 4, 2016

NaN is a fine (if weird) value to pass so we should probably just handle it explicitly like we did for props in #3148.

@jimfb
Copy link
Contributor Author

jimfb commented Jan 4, 2016

As per team discussion offline, we should warn on initial render (NaN indicates error) and also do as @zpao mentioned to avoid the mutation warning on update.

@jontewks
Copy link
Contributor

jontewks commented Jan 8, 2016

Submitted #5811 as a fix. Thanks!

@jimfb
Copy link
Contributor Author

jimfb commented Feb 3, 2016

Fixed in #5811

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

No branches or pull requests

3 participants