Skip to content

feat(brownie): add selector and equality fn support to useStore#175

Merged
okwasniewski merged 2 commits into
mainfrom
oskar/brownie-selectors
Jan 9, 2026
Merged

feat(brownie): add selector and equality fn support to useStore#175
okwasniewski merged 2 commits into
mainfrom
oskar/brownie-selectors

Conversation

@okwasniewski

@okwasniewski okwasniewski commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add optional selector and equalityFn params to useBrownieStore hook
  • Use useSyncExternalStoreWithSelector for optimized re-renders
  • Export shallow equality helper (zustand-style)
  • Add tests for shallow comparison
  • Update TesterIntegrated example with selector usage

New API:

// With selector - only re-renders when selected value changes
const [count, setState] = useStore('Store', s => s.count)

// With selector + shallow equality for objects
const [user, setState] = useStore('Store', s => s.user, shallow)

@okwasniewski okwasniewski force-pushed the oskar/brownie-selectors branch from 1a38943 to 36d0721 Compare January 9, 2026 12:17
@okwasniewski okwasniewski force-pushed the oskar/brownie-selectors branch from 36d0721 to 2f2ed68 Compare January 9, 2026 12:28
Comment thread packages/brownie/ArchitectureOverview.md Outdated
Comment thread packages/brownie/jest.config.js Outdated
Comment thread packages/brownie/package.json Outdated
Comment thread packages/brownie/src/shallow.ts Outdated
- rename useBrownieStore -> useStore
- use React's useSyncExternalStore instead of shim
- remove shallow equality fn (zustand-style API)
- replace ts-jest with babel-jest
@thymikee thymikee changed the title feat(brownie): add selector and equality fn support to useBrownieStore feat(brownie): add selector and equality fn support to useStore Jan 9, 2026
@okwasniewski okwasniewski merged commit f8aeecb into main Jan 9, 2026
4 checks passed
@okwasniewski okwasniewski deleted the oskar/brownie-selectors branch January 9, 2026 14:05
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

Successfully merging this pull request may close these issues.

2 participants