jeudi 18 avril 2019

Do I list the incoming data as a checkbox?

I'm pulling the data, but when I try to checkbox as a list. 'TypeError: Cannot read property 'map' of undefined' is the reason I'm getting this error?

I get the error 'this.state.action.map((action) => { return ()})' in place.

     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>
             )
           }




Aucun commentaire:

Enregistrer un commentaire