generalui / hooks-for-redux

modular redux - in half the code
MIT License
96 stars 13 forks source link

support for custom selectors #9

Closed shanebdavis closed 2 years ago

shanebdavis commented 2 years ago

I'd like to add the ability to optionally select a subset of the H4R redux slice and only re-render when that subset changes:

const [use, {...}] = createReduxModule('example', {foo: 1, bar: 2}, {...})

const MyComponent = () => {
  const foo = use(({foo}) => foo) // doesn't re-render if bar changes
  return ...
}
mattcgenui commented 2 years ago

This should take care of it: #11

shanebdavis commented 2 years ago

This is now in

shanebdavis commented 2 years ago

@mattcgenui Thanks for this! I finally got this released as version 2.1. I want to add typescript support for this too, so I created a new issue for tracking that effort (#14).