forma-36
forma-36 copied to clipboard
🐛 Bug - F36 v4 codemod migration TextField textInputProps
Forma 36 bug report
Summary
When trying to migrate to Forma36 v4 via the provided codemods the following error will occur when there is a TextField component has a textInputProps prop that has a variable (reference) instead of a direct object.
Example:
const textInputProps = {
type: 'text',
value: model[name].value,
onChange: (e) => update(assign(model, { [name]: { ...model[name], value: e.target.value } })),
disabled: !canEdit,
error: hasError ? 'error' : undefined,
};
<TextField
id={name}
name={name}
labelText={label}
helpText={description}
required={isRequired}
validationMessage={
hasError
? `This field needs to be between ${model[name].minLength} and ${
model[name].maxLength - 1
} characters`
: undefined
}
textInputProps={textInputProps}
formLabelProps={formLabelProps}
/>
Error message:
Transformation error (Cannot read properties of undefined (reading 'reduce')) TypeError: Cannot read properties of undefined (reading 'reduce')
Workaround:
Directly use the object inline or spread the object inline like textInputProps={{...textInputProps}}
Environment
Steps to reproduce
Expected results
Actual results
Marking issue as stale since there was no acitivty for 30 days
Since we have a workaround, I'll be closing this one, we may get back to it in the future if needed