Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6208

Mutually exclusive attributes using Flow

$
0
0

I'm building a UI component in the company I work for. It's in React Native and it uses Flow to typecheck. Thing is I want the components to have certain variants but they force me to have nothing but booleans for components attributes. And I'd like the components to disallow the use of more than one variant.

Let's say my component <Button> has two variants: primary and secondary. If I could use an attribute variant it would be easier because I would be able to use variant='primary'. But I can't do that. It has to be primary=true but I have to make it exclusive: if I have primary:true you shouldn't be allowed to use secondary:true in the same component.

I'been checking the docs but I couldn't find a way. And it makes sense, why would you have one? Just stop using boolean's for everything, right?

Question is: Is there a way?


Viewing all articles
Browse latest Browse all 6208

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>