Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
cómo hacer que el estado del componente no cambie si uso la función history.goBack()

Tengo un estado booleano y mi código depende de ese estado. Uno de ellos, si este estado es verdadero, usaré la función history.goback() , el segundo viene después de la primera condición. Verifico si el estado es falso y luego hago algo. pero lo que sucede ahora si history.goback() , el estado booleano se vuelve falso y luego se cumple la segunda condición. entonces como solucionarlo.

este es mi codigo

 const [isFormSubmitted, setIsFormSubmitted] = useState<boolean>(false); useEffect(() => { if (submitForm.status === RequestStatus.resolved) { setFormLoading(false); notification.success({ message: t('messages.success'), description: t('messages.success.requestCreated'), }); setIsFormSubmitted(true); } else if (submitForm.status === RequestStatus.rejected) { setFormLoading(false); notification.error({ message: t('leaves.newRequest.message.leaveRequestError'), description: submitForm.error?.message?.includes('Leave request already exists') ? t('leaves.newRequest.error.alreadyExists') : submitForm.error?.message, }); } }, [submitForm.status, t, submitForm.error?.message]); useEffect(() => { if (isFormSubmitted) { history.goBack(); } }, [history, isFormSubmitted]); const deleteProcessInstance = useCallback(async () => { if (isFormSubmitted === false && processInstanceIdRef.current) { try { ....... })); } catch { notification.error({ message: t('messages.error.wentWrong'), description: t('messages.error.tryAgainLater'), }); } } }, [leaveRequestPDK, isFormSubmitted, dispatch, t]); //this if the user leave the page then this useEffect hit useEffect( () => () => { deleteProcessInstance(); }, // eslint-disable-next-line react-hooks/exhaustive-deps [] );
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!