Skip to content
Advertisement

How to define an array with conditional elements in react

I have a arry called a tableFilterFields like this:

JavaScript

I want to apply a condition that If prop was not undefined ….How should I do this?

Advertisement

Answer

It would be better to do the conditional operation outside the array definition. You can achieve this by conditionally doing push operation

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement