DEV Community

loading...

Fetch w/ react

manuelalonge profile image Manuel Alonge ・1 min read

Hello, this is the repo I am working on: https://github.com/manuelalonge/covid-19-stats/tree/develop
I am currently trying to move the api call into the IndexPage component and then pass it as a prop to the child components (Graph, LastUpdate) but I am not sure what I am doing wrong.

Can anyone please help me out?
Thanks,
Manuel

Discussion (4)

Collapse
emma profile image
Emma Goto 🍙

I'm taking a look at your useStats hook and it seems to be correct.

What sort of errors are you running into?

Collapse
manuelalonge profile image
Manuel Alonge Author

Hi Emma,
I don't run in any error but I am not able to see the data of the components GraphData and LastUpdate.

Collapse
javila35 profile image
Joe Avila • Edited

It seems like Stats has state. If you wanted to pass state from Stats to your Graph + LastUpdate You'd need to set the state of IndexPage.

Collapse
javila35 profile image
Joe Avila

I haven't worked with it yet, but there's also a Context hook that apparently lets you skip passing through props.

Forem Open with the Forem app