main component
const handleOnClose = () => {};
return (
<TimeLapse onFinishTime={handleOnClose}/>
)
time lapse
const TimeLapse = observer(({ store, onFinishTime }) => {
useEffect(() => {
if (time.limitNumber && store.user.timeLapseInQuestion === 0) {
store.startCounterDownTime(100000, (() => {
onFinishTime(); // llamar a mi propFunction
}));
}
}, [time]);
...
store.js
const startCounterDownTime = (time, callbackFinish) => {
callbackFinish && callbackFinish();
}
in my component TimeLapse
when the callback is executed it startCounterDownTime
works correctly, the problem falls when it tries to call my propFuntion onFinishTime
that comes in the main component. Tells meTypeError: onFinishTime is not a function
Does anyone know why?
A common error in these cases is that you are probably using the TimeLapse component in several places, and in one of them you forgot to pass the TimeLapse function as props.