I have declared a variable with usestate
like as below
const [currentStepNumber, setCurrentStepNumber] = useState(0);
and then I am updating the state when I click on move function like as below
const handleMove = () => {
setCurrentStepNumber(currentStepNumber + 1);
const { label } = Object.values(PROJECT_PHASE).find(s => s.stepNumber === currentStepNumber);
const projectPhaseID = projectPhaseData.projectPhases.find(a => a.name === label).id;
console.log(currentStepNumber);
// need to do API call as well in move function
};
And the currentStepNumber
still shows 0
instead of 1
only and i cannot use a timer to trigger and update the values. Is there any other approach to achieve this?
I need to update the currentStepNumber
only in move function.