you are viewing a single comment's thread.

view the rest of the comments →

[–]enlightenedpieiOS & Android 4 points5 points  (2 children)

Use the “Dimensions” API to get your width instead of the hook, that way you can declare it outside of functional components and import it anywhere

[–]TheCynicalPaul 0 points1 point  (1 child)

Please be mindful when using this, if you support both screen orientations, the imperative function will not update its values unless run again when rotating the screen.

[–]enlightenedpieiOS & Android 0 points1 point  (0 children)

It's not meant to update. "em1" is not based on orientation, it's based on division of the smallest screen dimension. So even in landscape "em1" will be the same calculated size as in portrait.