limistah

I just learnt a short circuit form of these logical operators.To my fellow react …

Fri 26 Oct, 2018 11:06 pm

I just learnt a short circuit form of these logical operators.


To my fellow react guys.


Tell the output in each case:

// Define the component to old our text
const Text = ({text}) => (

{text}

); // Consume it here const App = ({text}) => (     
{text && }
); // Case 1 ReactDOM.render(, insertNode); // Case 2 ReactDOM.render(, insertNode);

Note there is a more clearer syntax that uses the ternary (logic ? truthReturn : falseReturn).

I just learnt this from reading through react-loading-screen library 

Another benefit of seeing what is inside the radio.


What will be rendered?

And why did the guy opted for this syntax.