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

472
Vistas
How can I check if url parameters exist with formik register form? Is there a ready exported function that does this from formik?

I want to assign a value to one of the initial values (referrerId), based on whether URL parameters exist or not. I have left out the other code which I believe is irrelevant for this question. When the form loads, I want the referrerId field to be prepopulated with id extracted from URL parameters.

<Form
  initialValues={{
    referrerId: // if there are no parameters set string "none" : referrer's id, which is extracted from params,
  }}
>

   <FormField 
      label="Referrer's Id"
      name="referrerId"
      placeholder="Referrer's Id"
      type="text"
   /> 

</Form>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

One way to make this possible is by using the URLSearchParams javascript interface.

const parameters = new URLSearchParams(window.location.search);

<Form
  initialValues={{
    referrerId: `${parameters.get('referrer-id')}`,
  }}
>

   <FormField 
      label="Referrer's Id"
      name="referrerId"
      placeholder="Referrer's Id"
      type="text"
   /> 

</Form>

and your url will look something like

https://mycoolwebsite.com/somepage?referrer-id=23221
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