score:1

you cannot modify a state directly

you can create a copy, shuffle it and reassign the state in this way

const shuffle = () => {
   setusedquestion(u => {
    const data = [...u]
    data.sort(() => math.random() - 0.5))
    console.log("shuffled : " + data);
    return data;
    }
   )
}

score:1

everytime you update a react state (eg. by calling setcurrentquestion) your component will rerender.
here, rerendering means it will execute the code of your function component again (function home()).
in the body of function home() you have this: let i = 0; so i will reset everytime you change a local state.

now what you probably want is to persist the current question index across multiple rerenders.

you could do nextquestion like this:

// remove: const [currentquestion, setcurrentquestion] = usestate(1);
const [currentquestionindex, setcurrentquestionindex] = usestate(0);
const currentquestion = usedquestions[currentquestionindex];

const nextquestion = () => {
  if (currentquestionindex < usedquestions.length) {
    setcurrentquestionindex(currentquestionindex + 1);
  } else {
    setcurrentquestionindex(0);
  }
};

you might have more tweaking to do but that should get you started


Related Query

More Query from same tag