Without useStyles
, you can’t utilize features like:
- breakpoints
- media queries
- themes
- variants
Hook that ties everything together and handles the heavy lifting.
Without useStyles
, you can’t utilize features like:
It can be imported from the react-native-unistyles
:
useStyles
accepts two optional arguments: stylesheet
and variants
.
To learn more about variants follow this guide.
If you need to access your theme
or the current breakpoint
in your component you can call useStyles
without any arguments:
For more advanced usage, pass your stylesheet
generated with createStyleSheet:
If you haven’t registered your breakpoints with UnistylesRegistry
it will be always undefined
.
Otherwise it’s will be defined string like sm
, md
or xl
.
With breakpoint
you can manipulate the JSX to hide or show some components:
Sometimes, you may need to access your theme
values outside of the stylesheet.
An example of this could be when working with a built-in React Native Button component.