Skip to content

Latest commit

 

History

History

03.problem.spread

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Spread props

What if I have an object of props that I want applied to the div like this:

const children = 'Hello World'
const className = 'container'
const props = { children, className }
const element = <div /> // how do I apply props to this div?

If we were doing raw React APIs it would be:

const element = createElement('div', props)

Or, it could be written like this:

const element = createElement('div', { ...props })

👨‍💼 See if you can figure out how to make that work with JSX. Take an object of props, and apply those props to a React element.

📜 Forwarding props with the JSX spread syntax