0

So I am pretty new to React.js and not able to render an element from the Route module. The console is returning that the leaf route at location does not have an element hence renders an empty page. Other Route tags which use "element" function work correctly, so does this one. This is a snippet from the App.js file

          <Route
        path="/"
        render={(props) => (
          <ContactList
            {...props}
            contacts={contacts}
            getContactId={removeContactHandler}
          />
        )}
      />

I have been following a youtube tutorial in hopes of learning React quickly. Now some of the functions used in this tutorial are deprecated currently. So is there a different function that I should be using instead of this? Appreciate any help

Edit: The render and component function both are replaced by element prop, i found this answer helpful

Brownpanda
  • 78
  • 1
  • 9

2 Answers2

0

The React router docs has recently been updated! Meaning syntax has changed. Take a look at this answer here.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 24 '22 at 15:44
0

If anyone wants to know, from version 6 onwards render and component props is replaced by element prop that is passed as a literal instead of through an arrow function ()=>{}. This answer explains it a bit more clearly.

Brownpanda
  • 78
  • 1
  • 9
  • 1
    apologies i meant element only. I had upvoted it, but for it be cast I need 15 reputation ;( Thank you for your answer though, helped me a lot . – Brownpanda Jan 25 '22 at 17:37