Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
React hook form - watch method rerender if there is less than 2 element in combobox

Today I am faced with a really strange issue and I can not solve it. I am using react query to fetch data for my Combobox.

const { isLoading, data } = useQuery('loadBranchBICRMA', loadBranchBIC)

and I am using form.watch for catching if there are any changes occurring in my Combobox because if there are some changes occurring I will check my DB and fill the rest of the form if there is a match.

const receiverBIC = form.watch('ReceiverBIC');
const senderBIC = form.watch("SenderBIC") ;
const [branchColumns] = React.useState(['none']);
const [messageTypeColumns] = React.useState(['accptdMsg','declndMsg']);

const validateRMA = () => {
    const URL = VALIDATE_RMA + `/${senderBIC}/${receiverBIC?.length === 8 ? receiverBIC+"XXX": receiverBIC}`
    axios.get(URL, {httpsAgent})
        .then((response) => {
            if (response.data !== ''){
                setSelectedAcceptedMessages(response.data.accptdMsg);
                setSelectedDeclinedMessages(response.data.declndMsg);
                setIsSave(true)
            }else setIsSave(false);
        }).catch();
}

useEffect(() => {if ( receiverBIC?.length !== 0 ) {validateRMA();}}, [receiverBIC,senderBIC]);

The problem is if there are less than 2 elements in my Combobox, form.watch rerender and crash my app. The strange part is why 2 elements :D any help will save me thx.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I still didnt understand why this problem occurring while less than 2 item in combobox but the solution is using useWatch instead of watch. It solved all my problems.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda