Multiple checkbox in redux-form

前端 未结 3 1143
攒了一身酷
攒了一身酷 2021-02-08 04:29

I would like to ask, here\'s the scenario. I have this multiple checkbox but my problem is whenever I tick one checkbox, all of the 4 checkboxes are selected. And also why is it

3条回答
  •  孤街浪徒
    2021-02-08 04:45

    For people like me who are new to redux and react may find the original code mentioned here confusing. I modified and converted it to an ES6 class. I also Removed bootstrap, validation and made it easy to debug.

    Here is the modified code

    import React from 'react';
    
    class CheckboxGroup extends React.Component {
    
        checkboxGroup() {
            let {label, required, options, input, meta} = this.props;
    
            return options.map((option, index) => {
                return (
                
    ) }); } render() { return (
    {this.checkboxGroup()}
    ) } } export default CheckboxGroup;

    Usage:

    let optionsList = [{id: 1, name: 'Optoin1'}, {id: 2, name: 'Option 2'}, {id: 3, name: 'Option 3'}]     
     
    

提交回复
热议问题