Skip to content

add shorthand for specifying pixel values in style props to docs #55

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

Merged
merged 4 commits into from
Oct 9, 2017

Conversation

xjlim
Copy link
Contributor

@xjlim xjlim commented Oct 7, 2017

Fix #27

image

@reactjs-bot
Copy link

reactjs-bot commented Oct 7, 2017

Deploy preview ready!

Built with commit f3aea25

https://deploy-preview-55--reactjs.netlify.com

return <div style={divStyle}>Hello World!</div>;
}
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the section about which props are unitless is also worth adding just to avoid potential confusion that all numeric style props are stringified like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be updated to reflect the latest changes in this file(20 of them are not on the list)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, or maybe just mention the type of props that aren't converted and list a few examples?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I left it as is and include a link to the file.

@bvaughn
Copy link
Contributor

bvaughn commented Oct 9, 2017

Thanks!

@bvaughn bvaughn merged commit 580706b into reactjs:master Oct 9, 2017
</div>
```

Not all style properties are converted to pixel strings though. Certain ones remain unitless (eg `zoom`, `order`, `flex`). A complete list of unitless properties can be seen [here](https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSProperty.js#L15-L59).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually got me curious -- while the first and second values of flex are unitless, the third is not. Luckily, it's not possible to provide more than one value other than as a string...

jhonmike pushed a commit to jhonmike/reactjs.org that referenced this pull request Jul 1, 2020
* Translate: Context

* Translate: Context first review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants