Closed rborn closed 1 year ago
i don't think you're doing anything wrong exactly, but i'm pretty sure i coded the implementation with an assumption that raw style objects would be passed last, and so, would always take precedence. i think i might have done that because usually you're only falling back to writing a style object when there is no utility class that does the job, so i didn't think there would be much issue about conflicting or overwriting other styles. there might be something as well related to the caching, but i can't remember.
so, i think basically you could consider this a bug. but i'm wondering if your use-case permits you to put the objects last to workaround it, or if for some reason that's not an option, because of some dynamic or runtime condition that might put them first.
Thanks for replying, the case would be a HOC where you'd want to force some styles to a component. Currently is more a theoretical case, but I'm exploring some ideas.
If I get to the point I need this I'll have a look and maybe propose a fix :)
A quick fix would be to map all string arguments to go again through tw.style
(not ideal though)
<View style={tw.style(styles.container,{backgroundColor:'blue'}, tw.style('bg-red-100') )}>
If we need to merge more styles with various formats, for some reason won't respect the order ( last in, last applied) - at least that's my understanding how it should work π
eg:
βThe
backgroundColor
will always beorange
βThe
backgroundColor
will always begreen
β However this works
β This too:
β And this too:
Any idea if I'm doing something wrong? Thank you