glamorous-native icon indicating copy to clipboard operation
glamorous-native copied to clipboard

Creating styles that can be passed as style prop

Open baba43 opened this issue 6 years ago • 1 comments

Hey,

I'm using an external library that only allows styling over different props (like containerStyle, textStyle, ...). Now I would like to know, if I can still use glamorous-native to create those styles because I'd like to use theme props.

Thank you very much.

baba43 avatar Oct 16 '18 17:10 baba43

Hi @baba43,

did you ever find the answer you were looking for?

Glamorous does not have built in support to target a different property other than style, but you can always map that prop to something else, for example:

const YourContainerStyledComponent = glamorous(({style, ...props}) => (
  <YourComponent {...props} containerStyle={style} />
))(yourStyles)

And if you do this frequently, or need to compose different props at the same time, this could be abstracted away into some HoCs

atticoos avatar Dec 20 '18 15:12 atticoos