Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

86
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda