Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS: Difference between functional component and a function which returns jsx

Tags:

reactjs

Consider the below function

function DummyComponent() {
   return (
      <div class='dummy'>
       <p> Hello world </p>
      </ div>
   )
}

Now DummyComponent can be used in two ways to render

Method 1:

<DummyComponent />

Method 2

<>
  {DummyComponent()}
</>

What is the difference between the two considering both get the job done? Are there any advantages or disadvantages for either of the two methods?

like image 592
Zer0 Avatar asked Jun 05 '26 14:06

Zer0


1 Answers

Method 2 is much fast, for further details, please go through link below.

https://medium.com/missive-app/45-faster-react-functional-components-now-3509a668e69f

like image 174
pankaj Avatar answered Jun 07 '26 05:06

pankaj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!