React store getters

hi
aren’t store getters supose to act like selectors in redux ?
once i use useStore on my getters, the first time it returnes my desired results but after the state changes it returns the state and not what i wrote on getter
this is my getter code :

ordersReport({ state }) {
  let ordersReport = {
    totalOrders: 0,
    completed: 0,
    pending: 0,
    processing: 0
  }

  state.ordersReport.forEach(orderReport => {
    switch (orderReport.slug) {
      case 'completed':
        ordersReport.completed += orderReport.total;
        ordersReport.totalOrders += orderReport.total;
        break;
      case 'pending':
        ordersReport.pending += orderReport.total;
        ordersReport.totalOrders += orderReport.total;
        break;
      case 'processing':
        ordersReport.processing += orderReport.total;
        ordersReport.totalOrders += orderReport.total;
        break;
      default:
        ordersReport.totalOrders += orderReport.total;
        break;
    }
  });

  return ordersReport
},

and this is how i use it :

const ordersReport = useStore(‘ordersReport’);

the first time it behaves correctly but when state changes it only shows the state.ordersReport even tho i didnt return it in getter …

help please , any suggestion would be helpfull

Seems like issue on F7 side. Already fixed in https://github.com/framework7io/framework7/commit/11ac75318a173ea86a185d3b782fdc142f742b29 so will be fixed in next update

1 Like