https://m7madmomani2.github.io/reading-notes2
Embedding Expressions in JSX In the example below, we declare a variable called name and then use it inside JSX by wrapping it in curly braces:
` const name = 'Josh Perez'; const element =
Hello, {name}
;
ReactDOM.render( element, document.getElementById('root') );
` You can put any valid JavaScript expression inside the curly braces in JSX. For example, 2 + 2, user.firstName, or formatName(user) are all valid JavaScript expressions.
After compilation, JSX expressions become regular JavaScript function calls and evaluate to JavaScript objects.
You may use quotes to specify string literals as attributes:
const element = <div tabIndex="0"></div>;
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components. You can find a detailed component API reference here.
The simplest way to define a component is to write a JavaScript function:
function Welcome(props) { return <h1>Hello, {props.name}</h1>; }
Components can refer to other components in their output. This lets us use the same component abstraction for any level of detail. A button, a form, a dialog, a screen: in React apps, all those are commonly expressed as components.