Trying To Block Users From Leaving Page Before Selecting Answer In React
I have a question component and am trying to prevent users from leaving a page before selecting an answer. this is my question component import React, { Component } from 'react'; i
Solution 1:
@jdip88, in the first glance, I can see you have not defined initial state correctly.
Can you please replace the following section and test it:
constructor(props){
super(props);
this.state={score: '',}
}
Solution 2:
If you read the error message carefully, you can deduce that this.state
is null, not this.state.score
like you mentioned - it is saying that score
is a property of null. As the other answer suggests, define an initial state in your constructor and go from there.
Post a Comment for "Trying To Block Users From Leaving Page Before Selecting Answer In React"