Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ When adding a customizable component: add it to `DEFAULT_COMPONENTS`, then read

`state-store/` holds `useSyncExternalStore`-based stores consumed with `useStateStore(store, selector)` for fine-grained subscriptions outside the context system. Define selectors at module scope so they stay referentially stable — an inline selector re-subscribes on every render.

**Always pass a selector, and make it declare what the caller reads.** `@stream-io/state-store` 1.4.0 lets `useStateStore(store)` run without one and return the whole state. Do not use that form here. A selector picks the fields the component actually reads (`({ selectedPicker }) => ({ selectedPicker })`), so the subscription says what it depends on and re-renders only when those fields change. Pick specific fields even when the hook returns them to callers. When a caller genuinely needs every change, such as a re-render trigger on `editingAuditState` or a hook whose contract is the whole state, write an explicit identity selector at module scope (`const editingAuditStateSelector = (state: EditingAuditState) => state;`) so the choice is visible in code review.

### Native module abstraction

`package/src/native.ts` declares TypeScript interfaces for every platform-specific capability (image picking, compression, haptics, audio/video, clipboard, share). Implementations are injected at runtime via `registerNativeHandlers()`: `stream-chat-expo` supplies Expo implementations, `stream-chat-react-native` supplies bare-RN ones. Calling an unregistered handler throws with a message naming the package to import.
Expand Down Expand Up @@ -239,7 +241,7 @@ Native pieces live in `package/shared-native/`: the Android-only `PerfText` Fabr
1. **Edit generated or synced files** (see below) — regenerate them instead.
2. **Key on `channel.cid` where you mean the channel instance** — depend on `channel` itself. A disposed channel comes back as a new instance under the same cid, so anything bound to the instance (a context value holding it, a `useStateStore` subscription, a listener, `watch()`) must rebuild when `channel` changes. Use `cid` only when you mean the conversation.
3. **Mutate `channel.state.messages` directly** — go through the `stream-chat` client's state API.
4. **Inline a `useStateStore` selector** — define it at module scope.
4. **Inline a `useStateStore` selector, or omit it** — define it at module scope, and always pass one (see [State stores](#state-stores)).
5. **Use unguarded web-only APIs in shared code** — it runs on Hermes, not a browser.
6. **Bypass lint or type errors** with broad disables or force merges.

Expand Down
2 changes: 1 addition & 1 deletion examples/SampleApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@react-navigation/native": "^7.5.0",
"@react-navigation/native-stack": "^7.20.0",
"@shopify/flash-list": "^2.3.3",
"@stream-io/state-store": "^1.3.1",
"@stream-io/state-store": "^1.4.0",
"dayjs": "^1.11.23",
"emoji-mart": "^5.6.0",
"lodash.mergewith": "^4.6.2",
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@gorhom/bottom-sheet": "^5.2.14",
"@legendapp/list": "^3.7.1",
"@stream-io/i18n": "^1.1.0",
"@stream-io/state-store": "^1.3.1",
"@stream-io/state-store": "^1.4.0",
"@ungap/structured-clone": "^1.3.0",
"dayjs": "^1.11.23",
"emoji-regex": "^10.4.0",
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6804,9 +6804,9 @@ __metadata:
languageName: node
linkType: hard

"@stream-io/state-store@npm:^1.2.0, @stream-io/state-store@npm:^1.3.1":
version: 1.3.1
resolution: "@stream-io/state-store@npm:1.3.1"
"@stream-io/state-store@npm:^1.2.0, @stream-io/state-store@npm:^1.3.1, @stream-io/state-store@npm:^1.4.0":
version: 1.4.0
resolution: "@stream-io/state-store@npm:1.4.0"
peerDependencies:
react: ^17 || ^18 || ^19
use-sync-external-store: ^1.5.0
Expand All @@ -6815,7 +6815,7 @@ __metadata:
optional: true
use-sync-external-store:
optional: true
checksum: 10c0/20d58fb89e1bca05ecd4a7d74bcdf01290053d3ddafb4ce4716279bbf68272f393e25ece4e7152adfe031ad582d3e8bce080901b6b66694663212dd8c55cf46f
checksum: 10c0/1ffdda249568297361688f0be77056b6654ee5216ef64b21ce0f0d6e4baccc210506ce815716c7bb46948c623786990e411736056d3c40d2fee7b218002f6ef6
languageName: node
linkType: hard

Expand Down Expand Up @@ -19730,7 +19730,7 @@ __metadata:
"@react-navigation/native-stack": "npm:^7.20.0"
"@rnx-kit/metro-config": "npm:^2.2.6"
"@shopify/flash-list": "npm:^2.3.3"
"@stream-io/state-store": "npm:^1.3.1"
"@stream-io/state-store": "npm:^1.4.0"
"@stream-io/typescript-config": "workspace:^"
"@types/lodash.mergewith": "npm:^4.6.9"
"@types/react": "npm:^19.3.0"
Expand Down Expand Up @@ -20563,7 +20563,7 @@ __metadata:
"@shopify/flash-list": "npm:^2.3.3"
"@shopify/react-native-skia": "npm:^2.13.0"
"@stream-io/i18n": "npm:^1.1.0"
"@stream-io/state-store": "npm:^1.3.1"
"@stream-io/state-store": "npm:^1.4.0"
"@stream-io/typescript-config": "workspace:^"
"@testing-library/jest-native": "npm:^5.4.3"
"@testing-library/react-native": "npm:13.2.0"
Expand Down
Loading