4

Does anyone know why you will call the component in this way. () => <Component/> inside the route enter image description here

Ice_mank
  • 68
  • 4

2 Answers2

2

You don't really have to do it this but if that works its just fine, i prefer doing it this way:

<Route exact path="/business" component={BusinessLanding} />

I hope this clears your doubt that there is no need to call a component like this () => <Component/> when you dont want to pass any props to the component

If you want to pass props you can do it this way:

<Route exact path="/business" component={({isOpen})=> <BusinessLanding open={isOpen} />} />
Gayatri Dipali
  • 667
  • 1
  • 12
  • Don't forget to upvote helpful answers and accept when you can the ones that solved your problem. Glad to help – Gayatri Dipali Nov 11 '20 at 04:52
  • if you think my answer is correct or useful kindly upvote it and if you agree that my answer is correct consider accepting it (you can do it by clicking the tick icon on the left of my answer) – Gayatri Dipali Nov 11 '20 at 09:02
2

If you wanna pass new props (eg. isAuth below example) or access props from React Router (eg. history, location, match)

<Route component={({history, location, match}) => <Component isAuth={isAuth} />} />
Kerem atam
  • 1,336
  • 10
  • 22