You can conditionally return it:
categories.map((i,j) =>{
return (i.svcName && <Tab label={'' + i.svcName} key={j}/> );
})
UPDATE
Reaction example:
const arr = [{
val: 1
},
{
val: 2
},
{
val: false
},
{
val: ''
},
{
noval: 'blahh'
},
{
val: 3
},
{
val: undefined
},
{
val: 4
},
]
const Tab = ({ value }) => <div className="tab">{value}</div>;
class App extends React.Component {
render() {
return(
<div>
{
arr.map((obj, i) => obj.val && <Tab value={obj.val} key={i} />)
}
</div>
);
}
}
ReactDOM.render(<App/>, document.getElementById('root'));
.tab{
height: 50px;
width: 100px;
display:inline-block;
background-color: #333;
color:#fff;
text-align:center;
border: 1px solid #fff;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
Run codeCHANGE
As noted @Chris in his reply, my approach eliminates values fakes , such as null, undefined, "", 0, NaN, etc.
source
share