Re-utilizing React Native styles with Styled Components
Published in
1 min readAug 21, 2017
Having to refactor some components to use styled-components
I felt the urge to reuse some existing styles created to be used with React Native StyleSheet
, directly on styled!
Let’s assume that:
- You are migrating a React Native app to use Styled Components,
- You have a Styles object somewhere on your code base with all your common styles, that looks something like this:
3. You have a component that uses that Styles
:
In case you don’t know, Styled Components allows for object interpolation directly in the styles declaration, so when migrating that component to use styled, it can be simplified like so:
Thanks Gabriel Rubens for the tip!