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

How to return a component only if the component returns something in a single line?

$
0
0

I have this code and I would like to be able to write this in a single line of code. Would that be possible?

If the component returns elements, return these elements from the parent component. Otherwise, do not return at all, but continue the script.

...const c = someComponent(var);if (c) return c;...

Edit

The purpose is that I want to make the code look cleaner, so ideally I would want it to look like this, where this function potentially replaces the output of the parent component and stops further execution.

...checkSomeVariables(var1, var2);...

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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