Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Smart" withArraySelector #6

Open
Mesqalito opened this issue Oct 24, 2023 · 0 comments
Open

"Smart" withArraySelector #6

Mesqalito opened this issue Oct 24, 2023 · 0 comments

Comments

@Mesqalito
Copy link

Suggestion: how about making "smart" withArraySelector, which applies shallow if selector is an array, and use default compare function in all other cases?

Example:

const useSmartStore = withSmartArraySelector(useExampleStore);

// shallow
const { bears, increaseBears } = useSmartStore(['bears', 'increaseBears']);

// Object.is
const wizards = useSmartStore((state) => state.wizards);

// Object.is
const entities = useSmartStore((store) => state.wizards + state.bears);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant