1

What I am trying to do:

I need to use hooks in my component but I setState already from the very start of the app which is giving me a delay.

What the overall Data Structure Looks Like:

  1. useState checks for changes in a let that changes the request url.
  2. The res is put in myList useState(res).
  3. myList is mapped out and the the res is broken apart to what will become the props for my Card component.
  4. in the card component I run a function which will pass updated values to other components inside of the Card component. To do this I put some props in another useState.

useEffect(()=>{fetchURL -> useState(res)},[url for fetch]) ---> props ---> useState(props) ---> function needed to change states

To fix this right now I am running useEffect to any changes to props inside the card component. It's messy, but it works. I am starting to learn redux so that will be the long term fix, but was hoping to ask if there was any conventional ways about how I should normally organize this data structure.

VI11age_ID10T
  • 161
  • 11

0 Answers0