title: TypeError: Cannot read properties of undefined (reading 'type')
body: <p>I'm trying to do a balance of incomes/expenses at my budget admin app and i keep getting this error at my balance component: TypeError: Cannot read properties of undefined (reading 'type').</p>
  <p>I think the problem may be related with the state I bring from my reducer that comes duplicated, 2 times with an empty array [] and 2 times full. I tried a lot but couldn't fix it.. any idea what it could be??</p>
  <p>This is my balance component code:</p>
  <pre><code>export default function Balance(){
  
      const operations = useSelector((state) =&gt; state.operations);
  
      console.log(operations);
      //Shows 4 arrays, 2 empty and 2 full
  
      const [total, setTotal] = React.useState([]);
  
      const operationsListCopy = [...operations];
  
      React.useEffect(() =&gt; {
  
          let entryArray = operationsListCopy.filter((oneOperation) =&gt; oneOperation.type == 'INCOME');
          let entryArrayTotal = entryArray?.reduce((amount, item) =&gt; item.amount + amount, 0);
  
          let exitArray = operationsListCopy.filter((oneOperation) =&gt; oneOperation.type == 'EXPENSE');
          let exitArrayTotal = exitArray?.reduce((amount, item) =&gt; item.amount + amount, 0);
              
          let arrayTotal = entryArrayTotal - exitArrayTotal;
  
          setTotal(arrayTotal);
      }, [operations]);
  </code></pre>