final-form / final-form/react-final-form

Warning when using material-ui radio group component

Open
#392 7 comments 10 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?
Not sure.
### What is the current behavior?
When I use a Material UI Radio Group, and don't pass `type="radio"` as a Field property I get a warning:

```
index.js:2178 Warning: Failed prop type: The prop `questions[0].questionId` is marked as required in `Questionnaire`, but its value is `undefined`.
```
The radio group works as expected in this scenario.

When I add the type="radio" attribute, the value is passes as undefined and the radio group stops working.

### What is the expected behavior?

No warning

### Sandbox Link
Data structure
for this value un checked (type="radio" not present)
```
answerId: null
questionId: "4ff412dd-c7af-488c-8661-098cf081910d"
```

data structure checked
```
answerId: "3f787b28-190d-4879-b99c-67f7c60bb31f"
questionId: "4ff412dd-c7af-488c-8661-098cf081910d"
```
Code
```

```
```
class RadioGroupField extends React.PureComponent {
render() {
const {
input,
label,
options,
required,
disabled,
helperText,
horizontal,
meta: { touched, error, submitFailed },
className,
} = this.props;
return (

{label}

{options.map(opt => (
}
label={opt.label}
/>
))}

{(touched && error) || helperText}

);
}
}
```
### What's your environment?
"react-final-form": 3.6.6
"react-final-form-arrays": "1.0.6",
"react": "16.6.0",

### Other information

```
index.js:2178 Warning: You must pass `type="radio"` prop to your Field(userAnswers[1].answerId) component.
Without it we don't know how to unpack your `value` prop - "undefined".
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.