I’m still having some trouble with the Random Quote Machine. Right now:
-Inside componentDidMount(), I have the fetch request to the external JSON file.
-It gets all the quotes data and saves it to a variable called myJson.
-I know it’s working because I can console.log individual quotes and authors from myJson.
The problem is:
-On line 23 when I try to use setState to give quotesData the value of myJson, it breaks the code.
-If I delete the setState, the 3 consoles that don’t rely on state will be logged.
I don’t really understand why setState is not working? Should componentDidMount() be calling a separate function to fetch the data and change the state?