forma-36 icon indicating copy to clipboard operation
forma-36 copied to clipboard

🐛 Bug - F36 v4 codemod migration TextField textInputProps

Open andreascful opened this issue 2 years ago • 1 comments

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

andreascful avatar Jun 22 '22 14:06 andreascful

Marking issue as stale since there was no acitivty for 30 days

github-actions[bot] avatar Aug 05 '22 07:08 github-actions[bot]

Since we have a workaround, I'll be closing this one, we may get back to it in the future if needed

massao avatar Sep 01 '22 08:09 massao