Reselect: can I use reselect with react-apollo?

Created on 28 Mar 2018  路  2Comments  路  Source: reduxjs/reselect

I took a look at the src code for createSelectorCreator and it seems to be pretty agnostic about a redux store. in fact, if state (and the Redux store is just a plain object) changes, we could get the same benefits of memoized/pre-computed state.

Say I have the results of a GraphQL query within a React Query component. If you don't have background, it's a HOC that reactively executes or passes a cached result of a GraphQL query.

So if within the component, we have:

<Query query={apolloQuery}>
   const { bob } = apolloQueryResults // aliased. it normally comes through as data

  const props = {
        prop1: memoizedPrecomputedSelector(bob)
   }

   return <ReactComponent { ...props}/>
</Query>

Would this achieve the same effect of memoization?

Most helpful comment

While Reselect is commonly used with Redux (and we recommend they be used together), Reselect is a totally generic memoization library. You can use it with values from React component state, or anything else.

All 2 comments

While Reselect is commonly used with Redux (and we recommend they be used together), Reselect is a totally generic memoization library. You can use it with values from React component state, or anything else.

yeehaw! that's awesome thanks

Was this page helpful?
0 / 5 - 0 ratings