react render div in function code example
Example 1: ternary react
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div>
The user is <b>{isLoggedIn ? 'currently' : 'not'}</b> logged in.
</div>
);
}
Example 2: javascript in jsx
const name = 'Josh Perez';
const element = <h1>Hello, {name}</h1>;
//notice the use of {...} to jump from jsx to javascript.
ReactDOM.render(
element,
document.getElementById('root')
);