title: How can I filter array of state in react?
body: <p>I have order reducer, which has many states.</p>
  
  <pre><code>const initialState = {
   channel: null,
   order: {},
   fetching:true,
   menu: [],
   categories: [],
   subcategories: [],
   currentCategoryId: 1,
   currentSubcategoryId: 5,
   currentMenu: [],
  };
  </code></pre>
  
  <p>What I want to filter is <code>menu</code>. <code>menu</code> is array of state which has objects of <code>menu_item</code> I have <code>currentCategoryId</code> and <code>currentSubcategoryId</code>. What I want to do with these states is that by using <code>currentCategoryId</code> and <code>currentSubcategoryId</code> to filter <code>menu</code> and put filtered states to <code>currentMenu</code>.</p>
  
  <pre><code>case Constants.ORDER_CHANNEL_CONNECTED:
   return
    {...state,currentMenu: action.menu.map((menu) =&gt; {
                      if(state.currentCategoryId == menu.category_id){
                          return menu;
                      }
                      else return false;}}
  </code></pre>
  
  <p>So to do that I made code like above. Even though it returns some filtered value, it shows same number of array with many false values. I want to find other approaches to do that..</p>
  
  <p>How can I do this? </p>
  
  <p>Thanks in advance.</p>