0

I am passing an array of objects as props to a child component in react, and to test whether it is working I have tried logging the props to the console. When I check the console, the props appear to have been logged to the console twice and I can't understand why. I've added an image of the code snippet just incase enter image description here


  const [quiz, setQuiz] = React.useState([])
  // const [currentId, setcurrentId] = React.useState({})

  React.useEffect(() => {
    console.log("use effect run!")
    fetch("https://the-trivia-api.com/v2/questions")
    .then(res => res.json())
    .then(data => {
      setQuiz(data)
    })
  }, [])
  
  return (
    <div className="App">
      { quiz.length > 0 ? 
        <Question {...quiz}/>
        : <h1>Page Loading...</h1> }
    </div>
  );
}```

0 Answers0