style={{ color: 'red' }} - What are the inner curly braces for?

Master ReactJS with our comprehensive test. Practice with multiple-choice questions and detailed explanations. Build your skills for the exam with our engaging format and expert tips!

Multiple Choice

style={{ color: 'red' }} - What are the inner curly braces for?

Explanation:
In React JSX, the style prop must receive a JavaScript object describing CSS properties. The outer curly braces indicate you’re inserting a JavaScript expression into JSX. Inside those, the inner curly braces create an object literal with style properties. So style={{ color: 'red' }} means: pass an object { color: 'red' } as the style value. This object tells React to apply the color red to the element. Remember that keys use camelCase (e.g., fontSize), and the outer vs inner braces distinguish the JSX expression from the object literal itself.

In React JSX, the style prop must receive a JavaScript object describing CSS properties. The outer curly braces indicate you’re inserting a JavaScript expression into JSX. Inside those, the inner curly braces create an object literal with style properties. So style={{ color: 'red' }} means: pass an object { color: 'red' } as the style value. This object tells React to apply the color red to the element. Remember that keys use camelCase (e.g., fontSize), and the outer vs inner braces distinguish the JSX expression from the object literal itself.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy