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

183
Vistas
Changing label at the Formik switcher

I created switcher with Formik. The switcher label should change as well. It works for now, but only with boolean value.

enter image description here

However, I need not boolean at the label but string. For example, instead of "true/false" a need to show "Text1/Text2".

Here is my code:

 const createItemTypeInitState = {
              item_type: false, // this boolean values works properly, switching the label text between true/false
              item_type_name: "Text1", // here should be the string values "Text1"/"Text2", depending on the switcher on/off
    };

  const [initialValues, setInitialValues] = useState<createItemData>(
    createItemTypeInitState
  );
            
        <FormControl component="fieldset" variant="standard">
            <FormGroup>
                 <FormControlLabel
                    control={
                       <Android12Switch
                           checked={values.item_type}
                           onChange={handleChange}
                           name="item_type"
                        />
                     }
                     label={`${values.item_type}`}
                 />
            </FormGroup>
        </FormControl>

So I need to change boolean value item_type to the string value item_type_name. Please help me do it.

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

0

I have decided it by myself. It should be:

label={values.item_type ? "Text1" : "Text2"}
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