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

85
Vistas
Set defaultValue via props

i have this two components

<Field
  component={renderTextField} 
  id="jobTitle"
  label={t("field1")}
  name="jobTitle"
  required
  defaultValue={isOfferCopied ? job.jobName ? "Test"}
/>

export const renderTextField = (props) => {
  const {
    input,
    meta: { touched, invalid, error },
    endAdornment,
    ...restProps
  } = props;
  return (
    <TextField
      {...input}
      {...restProps}
      variant="outlined"
      error={touched && invalid}
      helperText={touched && error}
      InputProps={{ endAdornment }}
      // margin='dense'
    />
  );
};

Im triyng to send defaultValue prop in Field component, but the output is empty. How can i solve this?.

Thanks to everyone in advance!

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can either set the default whole Prop object here:

export const renderTextField = (props = { input = 'somedefaultInput', endAdornment = 'eye', meta = { touched: false, invalid: false, etc }) => {

Or you can also default when you are defining the const

  const {
    input = 'someDefaultInput',
    meta: { touched, invalid, error } = { touched: false, invalid: false, error: null },
    endAdornment = 'eye',
    ...restProps
  } = props;

I also would highly recommend being explicit with the props that you are destructuring and avoid the ...restProps

about 4 years ago · Santiago Trujillo 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