javascript - How to skip null while map? JSX -


i'm new reactjs/redux , jsx. have dynamical table dynamic information in it.

i have problem map. have 2 levels of map:

<tbody>   {     data.map(row => (       <tr key={`${row.type}`}>         <td>           <h5>{row.type}</h5>         </td>         <td>           {             row.text.map((name, indextext) => (                <span key={row.text[indextext]} classname="margin-right-10">                  <link                    key={name}                    role="button"                    onclick={ () => this.getdata(                    this.state.le_id,                    row.text[indextext][1],                    row.type,                    this.state.year,                   )}>                    {row.text[indextext][0]}                  </link>                </span >             ))           }         </td>           <td>               <link classname="btn btn-info btn-sm"                     to={`/company/insurances/all-providers/${row.type}/${this.state.le_id}`}               >               {locales('create')}               </link>           </td>        </tr>     ))   } </tbody> 

here full picture how looks in action: image here

when select in filter other condition there somewhere null in array stop , show me error:

list.js?6d8a:153 uncaught (in promise) typeerror: cannot read property 'map' of null     @ eval (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:8972:1), <anonymous>:238:35)     @ array.map (native)     @ listsaccounting.render (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:8972:1), <anonymous>:222:26)     @ eval (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:796:21)     @ measurelifecycleperf (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:75:12)     @ reactcompositecomponentwrapper._rendervalidatedcomponentwithoutownerorcontext (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:795:25)     @ reactcompositecomponentwrapper._rendervalidatedcomponent (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:822:32)     @ reactcompositecomponentwrapper._updaterenderedcomponent (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:746:36)     @ reactcompositecomponentwrapper._performcomponentupdate (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:724:10)     @ reactcompositecomponentwrapper.updatecomponent (eval @ <anonymous> (http://localhost:3000/main-7a3d3e8ea9d6afcdba75.min.js:16034:1), <anonymous>:645:12) 

here error in action: image here

how skip null values in jsx while mapping , elements there empty indexes in places?

try this

row.text && row.text.map((name, indextext) ... 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -