'How can I go to the previous step

I am trying to make a quiz app from a json file. How can i make the back button go to the previous step. So I want to make the back button returns to what was previously selected.

 const navigate = () => {
        axios.get('http://localhost:5000/steps')
          .then((res) => {
            console.log(res);
            const step = res.data.filter((element: any) => element.id === destinationstepId)
            console.log(step);
            setData(step[0]);
            // setdestinationStepId(destinationstepId);
          })
      }
      const navigateBack = () => {
        let index = 1;
        axios.get('http://localhost:5000/steps')
          .then((res) => {
            console.log(res);
            const current = res.data.filter((element: any) => destinationstepId === element.id)
    
    
          })
     return (
        <div>
          {data.title}<br />
          {data.type === "qs" ?
            data.options?.map((step: any, index: number) => (
              <div key={index}>
                <input type="radio" onChange={() => handleStepChange(step.destinationStepId)}
                  name="stepOption" checked={isChecked === step.destinationStepId} />{step.optionTitle}
              </div>
            )) :
            data.instruction}
      </div>
        </div>
      )


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source