S
S
Smuzzzzi2020-06-06 11:23:36
React
Smuzzzzi, 2020-06-06 11:23:36

What is the difference between the components?

It works fine either way, what's the difference?

export default function App() {
  return (
    <div></div>
  )
}

export const App = () => {
  return (
    <div></div>
  )
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-06-06
@Smuzzzzi

There is a theoretical difference, but in practice - rather none, except that in one case you define a default import, and in the second a named one.
In theory:
1. The second arrow function works a little differently than the usual one.
2. In the first case, Function Expression, in the second, Function Declaration: what's the difference . Although, here I'm not sure about the context of the import - maybe this is always considered a declaration.
If you answer exactly in the context of React components, then there is no difference in the above code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question