React jsx attributes

I read this attribute expression with jsx, and can’t figure when to use “” and {}?

Attribute Expressions
To use a JavaScript expression as an attribute value, wrap the expression in a pair of curly braces ({}) instead of quotes ("").

// Input (JSX):
var person = <Person name={window.isLoggedIn ? : ''} />;
// Output (JS):
var person = React.createElement(
  {name: window.isLoggedIn ? : ''}

How to solve this syntax error: EDIT: SOLVED

React-specific attributes are always in curly braces, which indicates a javascript expression. You might use quotes in some of the html elements inside, e.g. type="input" for a text entry, but never in a react component.

1 Like