Trax
Trax

Reputation: 1538

Difference between <ComponentName /> and ComponentName()?

I am just wondering if there is a difference between the way <SomeComponent> is added to <Layout>. Is one way better than the other or is there a reason to use one and not the other?

const SomeComponent = () => {
  return (
    <Text> Some Text </Text>
  )
}

<Layout>
  <SomeComponent />
  {SomeComponent()}
</Layout>

Upvotes: 1

Views: 37

Answers (1)

George
George

Reputation: 3030

<SomeComponent> is just JSX syntax for SomeComponent(). They're the same thing.

And with Props:

<Layout>
  <SomeComponent prop1={someVariable} />
  {SomeComponent({prop1: someVariable})}
</Layout>

Upvotes: 2

Related Questions