Answers for "functions are not valid as a react child"

1

functions are not valid as a react child

//instead of passing in a function as a child
   ❌     //this is not the correct way of doing it 
const MyElement = () =>(   
	<>
  		<h2>This is a sample element</h2>
  	</>
)

...return( <MyElement/>)
                 
  ✅     //do this instead   
const MyElement = (		
    <>
      <h2>This is the correct way</h2>
    </>
)

...return( <MyElement/>)
Posted by: Guest on December-26-2021

Code answers related to "functions are not valid as a react child"

Code answers related to "Javascript"

Browse Popular Code Answers by Language