I have a function in the that fetches the weather data for current location when button is clicked. I want to get this data from the Location component to the pages/index.tsx where I have another components that displays that data.
This is my component structure:
App
--Layout
--Header
--Location (here i fetch the data on click)
--Home (state)
--Display 1
--SubDisplay 1
--Display 2
Do I have to pass the data through all the components to the index page? It would be:
- UP from Location to Header
- UP from Header to Layout
- DOWN from Layout to Index page
- DOWN from Index page to another components
Is this the best way to handle this?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/GZxKLEV
Comments
Post a Comment