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