Reputation: 47
I am making a simple Quiz app using React Hooks.
I pass a question
object into a ResultModel
component.
Here I
console.log
the question
object before passing it into the ResultModel
component.
Here I
console.log
the question
object inside of ResultModel
component.
Here is the result... I get an empty
question
object.
Upvotes: 1
Views: 651
Reputation: 85022
You're missing the curly brackets for destructuring the props. The variable you've called question
is actually the context object.
The fix is to do this:
export default function ResultModal({ isCorrect, question, getQuestion}) {
Or if you prefer, don't destructure in the argument list:
export default function ResultModal(props) {
const { isCorrect, question, getQuestion } = props;
Upvotes: 4