Reputation: 1352
For instance, this code snippet:
React.createElement(
"h1",
null,
"Shopping List for ",
props.name
),
What does the null value represent, or what can it be used for?
Upvotes: 2
Views: 7133
Reputation: 6145
From the React docs:
createElement()
React.createElement( type, [props], [...children] )
Create and return a new React element of the given type. The type argument can be either a tag name string (such as
'div'
or'span'
), a React component type (a class or a function), or a React fragment type.
What the docs don’t explicitly mention is that props
should be an object. For example:
{
click: dothing,
className: 'myClass'
}
It may be {}
or null
if you need to specify children but not properties
Upvotes: 7