Zer0
Zer0

Reputation: 458

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

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?

Upvotes: 3

Views: 704

Answers (1)

pankaj
pankaj

Reputation: 93

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

Upvotes: 1

Related Questions