Reputation: 96
I am trying to pass argument name in React.createElement()
and I failed. And I want to use JSX only. Here is my code:
const Main = (props) => {
return React.createElement(
'div',
null,
React.createElement('h1', {props.name})
)
}
Upvotes: 0
Views: 346
Reputation: 4770
The second argument to createElement is the props we are passing to the component and third argument is the children, here props.name
needs to be the child of h1 tag
React.createElement('h1', null, props.name);
You can verify this from the online babel compiler
Upvotes: 1