0

This is my file Structure

./src
 ./components
   Tabnav.js
   CharacterList.js
App.js

In my App.js file, I used Axios to fetch data from an Api, then I returned the 'CharacterList' component, passing it the properties gotten from the fetch results.

In my CharacterList component, I received the data from App.js through props and mapped over it to populate a list of the result I got. It worked fine and displays accurately.

In my Tabnav component I imported Route and while passing the CharacterList component to Route like this <Route path="/characters" component={CharacterList} /> I receive a TypeError: Cannot read property 'map' of undefined whenever I click on the link.

Without Route my data displays fine but with Route it returns 'map' error. What is going on here please and how can I solve this issue?

Thanks!

Evans I.
  • 11
  • 4
  • You should show some code, else there will be no help on SO – Panther Sep 21 '19 at 15:18
  • When `CharacterList` is called from route, does it receives the same props that it used to receive when it was under `Tabnav`. My guess is you are `mapping` over an prop which is not available. – Panther Sep 21 '19 at 15:20

0 Answers0