Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

83
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!