title: How to reset state on submit button sreact redux
body: <p>I have been struggling to reset the state on handleSubmit function. There are 3 questions that are coming one by one and on submit the next 3 questions should come like 1/3, 2/3 and 3/3 and this process goes on till all the questions are not submitted. Here is the code below:</p>
  <pre><code>const Quiz = () =&gt; {
      const { questions, quiz, options } = useSelector((state) =&gt; state.quiz);
      
      const [currentQuestion, setCurrentQuestion] = useState(0);
      console.log(currentQuestion[number] + &quot;1q&quot;);
      
      const dispatch = useDispatch();
      const history = useHistory();
      const location = useLocation();
      const classes = useStyles();
      
  
      // this is to get the questions from the history coming from redux store.
      useEffect(() =&gt; {
          if (!questions) {
              dispatch(fetchQuestions(history));
          }
      }, []);
  
        const handleRadioChange = (number, event) =&gt; {
          let currentSelection = questions.find(question =&gt; question.number === number);
          console.log(currentSelection + &quot;radio selected&quot;);
          currentSelection.value = event.target.value;
          console.log(currentSelection.value + &quot;calculate score&quot;);
          // Set the new question count based on the current one
          setCurrentQuestion((current) =&gt; {
            return Math.min(
              current + 1,
              questions.length - 1
            );
          });
      };
  
      const handleSubmit = (event) =&gt; {
          event.preventDefault();
  const valid = questions.some((q) =&gt; !q.value);
          console.log(valid + &quot;questionsalpha&quot;);
          if (!valid) {
              dispatch(postQuiz({ responses: questions, id: quiz.id }, history));
          }
  // this i added to get the question process repeat as earlier, but not working.
      setCurrentQuestion((current) =&gt; {
              return Math.min(
                current + 1,
                questions.length - 1
              );
            });
      };
      return (
          !questions?.length ? &lt;CircularProgress /&gt; : (
              &lt;Grid className={classes.container} container alignItems=&quot;stretch&quot; spacing={1}&gt;
                  &lt;form onSubmit={handleSubmit}&gt;
                      {/* Only show the question if it's index is less than or equal to the current question */}
                      {questions.map((question, index) =&gt; {return index &lt;= currentQuestion ? (
                          &lt;FormControl component=&quot;fieldset&quot; key={question.number} className={classes.formControl} data-hidden={question.number !== current_question[question.number]}&gt;
                              &lt;FormLabel component=&quot;legend&quot;&gt;{question.question}&lt;/FormLabel&gt;
                              &lt;RadioGroup aria-label=&quot;quiz&quot; name=&quot;quiz&quot; value={question.value} onChange={(e) =&gt; handleRadioChange(question.number, e)}&gt;
                                  {options.map((option) =&gt; 
                                      &lt;FormControlLabel key={option.score} value={option.score} control={&lt;Radio /&gt;} label={option.label} /&gt;
                                 )}
                              &lt;/RadioGroup&gt;
                          &lt;/FormControl&gt;
                      ) : null})}
                      &lt;Button type=&quot;submit&quot; variant=&quot;outlined&quot; color=&quot;primary&quot; className={classes.button}&gt;
                          Submit
                  &lt;/Button&gt;
                  &lt;/form&gt;
              &lt;/Grid&gt;
          )
      );
  };
  
  export default Quiz;
  </code></pre>
  <p>As user submitted the form, the question should appear one by one and if user refresh the page in between it should show the same page where he lefts, not the new url.
  Please help</p>