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!
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