Skip to content

Update the support of percentage in documentation of Height And Width file#2079

Closed
MianJawadAhmad wants to merge 3 commits into
react:masterfrom
MianJawadAhmad:HeightAndWidth-documentation-fix
Closed

Update the support of percentage in documentation of Height And Width file#2079
MianJawadAhmad wants to merge 3 commits into
react:masterfrom
MianJawadAhmad:HeightAndWidth-documentation-fix

Conversation

@MianJawadAhmad

Copy link
Copy Markdown

The support of percentage is added two years ago
Update the support of percentage in documentation of Height And Width file

@react-native-bot

Copy link
Copy Markdown

Deploy preview for react-native ready!

Built with commit cfbd39b

https://deploy-preview-2079--react-native.netlify.app

Changes to docs/ are reflected in the next "master" version.

Thank you for your contributions.

How to ContributeDocumentation Sources

Comment thread docs/height-and-width.md
## Fixed Dimensions

The general way to set the dimensions of a component is by adding a fixed `width` and `height` to style. All dimensions in React Native are unitless, and represent density-independent pixels.
The general way to set the dimensions of a component is by adding a fixed `width` and `height` to style. All dimensions in React Native are not unitless it supports percentage and represents density-independent pixels.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

From the technical point of view dimensions in React Native are unitless - every method related to the dimensions will return an integer (not a string with unit, like for example in CSS) which is a density pixels value. Later in the process many different operations on that value can happen (for example: multiplication by Pixel Ratio, conversion).

For arranging views React Native uses Yoga layout which besides DP and percentage allow specifying "auto" as value (which is also a default). You can find more information about the supported values in the Yoga documentation.

@Simek

Simek commented Jul 26, 2020

Copy link
Copy Markdown
Collaborator

@MianJawadAhmad I have created the separate PR to fix the problem in more broad way. In addition to my comment above I have noticed that percentage values mention should not be placed inside the Fixed dimensions section (to avoid potential users confusion). That means that I would have to drop/rollback all the introduced changes even if I would be working from you branch.

@nearestnabors

Copy link
Copy Markdown
Contributor

I'm approving @Simek's branch and closing this one, but thank you @MianJawadAhmad for bringing this discrepancy to our attention!

sm_thanks

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