How do i access a local state inside the mapstatetoprops method

513 views Asked by At

Thanks in advance.

Below is the snippet

const mapStateToProps = (state) => {
  const { itemReducer } = state;
  return {
    itemTree: getItemTree(itemReducer),
  };
};

getItemTree is a selector, and i would like to have another selector something like getFilteredItemTree. This transition should based on a local state. How do i access a local state or variable in this function. Or is there any other way to work on this.

1

There are 1 answers

0
Muhammad Ali On

You can access props passed to this component through 2nd param of mapStateToProps but you can't access local state of the component. What you can do is pass the whole data in the component and then filter it in the component's lifecycle hook.