是否将输入的数据作为复选框列出?

时间:2019-04-18 07:39:08

标签: arrays reactjs checkbox redux

我正在提取数据,但是当我尝试复选框作为列表时。

  

TypeError:无法读取未定义的属性“ map”

是我收到此错误的原因吗?

我收到错误信息this.state.action.map((action) => { return (<CheckBox {...action} />)})

     Console.log(data) : 
            (5) [{…}, {…}, {…}, {…}, {…}]
               0: {id: "816f4329-b74b-4a3b-b3c3-b81fec6f51a1", 
                actiontype: "Called & VM"}
               1: {id: "074979a4-6e4b-4bfc-8971-6898f9fd0127", 
                 actiontype: "Keep an Eye"}
               2: {id: "2e158344-39ca-46ce-a3fa-9d96d039194d", 
                 actiontype: "Follow Up"}
               3: {id: "81eed538-ccb5-4f5f-99f6-3531dc7941b6", 
                 actiontype: "Uninstall"}
               4: {id: "1e21f4af-c009-4897-96ad-33d3caacddc0", 
                 actiontype: "Emailed"}
               length: 5
               __proto__: Array(0)

     Code:  
          state = {
            action: [],
          }
          render() {
             this.state.action = this.props.ActionType.items
          return (

             <div className='popupAddAction'>
                <h1> Check and Uncheck All Example </h1>
                  <ul>
                {
                    this.state.action.map((action) => {
                        return (<CheckBox {...action} />)
                    })
                } 
               </ul> 
            </div>

      Checkbox Component:
           const CheckBox = props => {
             return (
                <li>
             <input key={props.id} type="checkbox" 
               value={props.actiontype} /> 
              {props.actiontype}
                </li>
             )
           }

0 个答案:

没有答案