Does redux-form field value can hold object instead of just a string?
Consider following example
class SelectQuestions extends Component{
TL:DR
Yes it can hold an object. Check out this example: https://codesandbox.io/s/vq6k6195rl
Explanation:
For a select, you can define your selects like this:
const myFancyQuestions = [
{ id: 1, label: 'Why?', category: 'Asking why' },
{ id: 2, label: 'Who?', category: 'Asking who' },
{ id: 3, label: 'When?', category: 'Asking when' }
];
Then wrap your component with Field component.
And then just show it in your render:
class ObjectSelect extends React.Component {
render() {
const { input, multiple, options, value, ...rest } = this.props;
const parse = event => {
// This is what redux-form will hold:
return JSON.parse(event.target.value);
}
return (
)
}
}