I use Redux and react, and in timer after one second get value of redux state. Each time the Timer is executed, the value of the state does not change and it is the initial value .initial value in state is
00:00:00
note: The value in the state is correct, only in the timer the value is wrong and the initial value.
CheckTheEndOfTheExam = setInterval(() => {
handleSendWxamDataAfterEndTime();
}, 60000);
const handleSendWxamDataAfterEndTime = () => {
if (getTimeToAttendTheExamPage == data1.examParents[0].examParent_duration) {
alert('زمان امتحان تمام شده است!!!');
}
}
const mapStateToProps = createStructuredSelector({
getTimeToAttendTheExamPage:getTimeToAttendTheExamPage,
});
You can update the state using
setState callback
and callhandleSendWxamDataAfterEndTime
function inside theuseEffect
hook.