Dimensions π - updated Docs π & new snack examples β¨#1601
Dimensions π - updated Docs π & new snack examples β¨#1601DaniAkash wants to merge 1 commit intofacebook:masterfrom
Conversation
|
Deploy preview for react-native ready! Built with commit 4744b09 https://deploy-preview-1601--react-native.netlify.com Changes to Thank you for your contributions. |
|
|
||
| ### React Native Hooks | ||
|
|
||
| You can also try [useDimensions](https://github.com/react-native-community/react-native-hooks#usedimensions) hook from [React native hooks](https://github.com/react-native-community/react-native-hooks) library which makes handling screen/window size changes much simpler. |
There was a problem hiding this comment.
RN actually ships its own useWindowDimensions hook now:
https://github.com/facebook/react-native/blob/8d57691a606ce81e6d861f93ccc11875088f58b6/Libraries/Utilities/useWindowDimensions.js
The docs should probably describe that hook here instead
There was a problem hiding this comment.
Thanks, I didn't knew!
| | dim | string | Yes | Name of dimension as defined when calling `set`. @returns {Object?} Value for the dimension. | | ||
| | Name | Type | Required | Description | | ||
| | ---- | ------ | -------- | -------------------------------------------------------------------------------------------- | | ||
| | dim | string | Yes | Name of dimension as defined when calling `set`. @returns {Object?} Value for the dimension. | |
There was a problem hiding this comment.
| | dim | string | Yes | Name of dimension as defined when calling `set`. @returns {Object?} Value for the dimension. | | |
| | dim | string | Yes | Name of dimension (`"window"` or `"screen"`). | | |
| Returns an object with four number fields: `width`, `height`, `scale`, and `fontScale`. |
It seems weird to me to reference set from the documentation for get, and the @returns is just a copy-paste from the code. scale and numberScale should maybe be documented better here, but honestly, I don't really know much about them!
There was a problem hiding this comment.
Indeed, these areas could use some more detail. I'll try them out and update the docs
|
In the first example documentation is suggesting rounding Currently proposed examples do not utilize |
|
Closing it in favour of #1671 |
Belongs to #1579
Inspiration - To address this stackoverflow question
Contains the snack with both class & functional component examples and also a bit of update to the documentation regarding screen, window & event listener.
Pending items in this PR:
useDimensionshook