Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Statements vs. Expressions.
const MyComponent = () => { return ( <> <h1>Hello world</h1> { arr.map(val => <ListItem val={val} />) } <h1>Goodbye world</h1> </> ); }
In functions:
const x = () => { }; // or function myFunc() { };
if (x > 2) { return true; }
while (x > 2) { doSomething(); }
This is obviously part of the language grammar of many languages and makes it obvious why React uses curly braces as well for interpolating values.
There are no comments on this comment yet.
In functions:
In conditionals (while the conditionals are statements their bodies are expressions) In Loops etc.This is obviously part of the language grammar of many languages and makes it obvious why React uses curly braces as well for interpolating values.