How to "if true, hide label text" in react storybook

Viewed 20

As above, if hideText is 'True', 'label' text will be disabled and not shown in my button. How to achieve this?

enter image description here

1 Answers

Depends on your code but you can generally use ternary operators within jsx.

So where you have your text and want to only show it when the hideText is false you can do a simple condition: { hideText ? (null) : (text) }

so 'hideText ?' evaluates the value of hideText variable/state. Then you have (return value if true) : (return value if false).

Related