From d1967e7232c827c5bbfff03abcaf1a48011403a8 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Thu, 3 Dec 2026 14:11:01 +0100 Subject: [PATCH 1/3] fix(deps): bump @stream-io/state-store to 1.4.0 --- examples/SampleApp/package.json | 2 +- package/package.json | 2 +- yarn.lock | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/SampleApp/package.json b/examples/SampleApp/package.json index 649e21bf4e..9086f4e34d 100644 --- a/examples/SampleApp/package.json +++ b/examples/SampleApp/package.json @@ -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", diff --git a/package/package.json b/package/package.json index aafa32c1ba..46b702f40c 100644 --- a/package/package.json +++ b/package/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 41431783a4..90c9d31d28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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 @@ -6815,7 +6815,7 @@ __metadata: optional: true use-sync-external-store: optional: true - checksum: 10c0/20d58fb89e1bca05ecd4a7d74bcdf01290053d3ddafb4ce4716279bbf68272f393e25ece4e7152adfe031ad582d3e8bce080901b6b66694663212dd8c55cf46f + checksum: 10c0/1ffdda249568297361688f0be77056b6654ee5216ef64b21ce0f0d6e4baccc210506ce815716c7bb46948c623786990e411736056d3c40d2fee7b218002f6ef6 languageName: node linkType: hard @@ -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" @@ -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" From 0823c756e89b9fb1575d6fcb2dd28488747fedd5 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Thu, 3 Dec 2026 14:34:53 +0100 Subject: [PATCH 2/3] refactor(store): drop identity selectors in favor of useStateStore without a selector --- .../store/bottom-sheet/useBottomSheetState.ts | 9 ++------- .../components/Channel/hooks/useSupersededChannelSwap.ts | 5 ++--- .../components/Chat/hooks/useNetworkConnectionState.ts | 4 +--- .../src/components/Chat/hooks/useWSConnectionState.ts | 3 +-- .../ScheduledMessages/ScheduledMessageSaveButton.tsx | 6 ++---- .../hooks/useMessageComposerHasSendableData.ts | 5 +---- package/src/hooks/useAttachmentPickerState.ts | 7 +------ 7 files changed, 10 insertions(+), 29 deletions(-) diff --git a/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts b/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts index 2d5f57ac4d..a5ad3d54b6 100644 --- a/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts +++ b/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts @@ -1,10 +1,5 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; -import { type BottomSheetState, sheetStore } from './store'; +import { sheetStore } from './store'; -const selector = ({ open, height }: BottomSheetState) => ({ - open, - height, -}); - -export const useBottomSheetState = () => useStateStore(sheetStore, selector); +export const useBottomSheetState = () => useStateStore(sheetStore); diff --git a/package/src/components/Channel/hooks/useSupersededChannelSwap.ts b/package/src/components/Channel/hooks/useSupersededChannelSwap.ts index bfe761a494..7334cbf055 100644 --- a/package/src/components/Channel/hooks/useSupersededChannelSwap.ts +++ b/package/src/components/Channel/hooks/useSupersededChannelSwap.ts @@ -1,9 +1,8 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; -import type { Channel, ChannelStateData, EditingAuditState } from 'stream-chat'; +import type { Channel, ChannelStateData } from 'stream-chat'; const supersededBySelector = ({ supersededBy }: ChannelStateData) => ({ supersededBy }); const activeSelector = ({ active }: ChannelStateData) => ({ active }); -const editingAuditStateSelector = (state: EditingAuditState) => state; /** * The instance `` renders: the one that superseded `channel`, which receives the events @@ -19,7 +18,7 @@ export const useSupersededChannelSwap = ( const { supersededBy } = useStateStore(channel?.state, supersededBySelector) ?? {}; const successorActive = useStateStore(supersededBy?.state, activeSelector)?.active ?? false; // Re-renders on every composer change so the emptiness read below stays current. - useStateStore(channel?.messageComposer.editingAuditState, editingAuditStateSelector); + useStateStore(channel?.messageComposer.editingAuditState); const composerIsEmpty = channel?.messageComposer.compositionIsEmpty ?? true; if (!supersededBy || (successorActive && !composerIsEmpty)) return channel; diff --git a/package/src/components/Chat/hooks/useNetworkConnectionState.ts b/package/src/components/Chat/hooks/useNetworkConnectionState.ts index 243e5c5b69..cb6b3a4451 100644 --- a/package/src/components/Chat/hooks/useNetworkConnectionState.ts +++ b/package/src/components/Chat/hooks/useNetworkConnectionState.ts @@ -3,8 +3,6 @@ import type { NetworkConnectionState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -const identity = (state: NetworkConnectionState) => state; - /** * The device's network status, as reported by the NetInfo listener `` registers on * `client.networkConnection`. Unlike {@link useWSConnectionState}, it is not affected by the socket @@ -19,7 +17,7 @@ const identity = (state: NetworkConnectionState) => state; */ export const useNetworkConnectionState = () => { const { client } = useChatContext(); - return useStateStore(client?.networkConnection?.state, identity); + return useStateStore(client?.networkConnection?.state); }; /** diff --git a/package/src/components/Chat/hooks/useWSConnectionState.ts b/package/src/components/Chat/hooks/useWSConnectionState.ts index 607e8ac968..f6cefa2f0c 100644 --- a/package/src/components/Chat/hooks/useWSConnectionState.ts +++ b/package/src/components/Chat/hooks/useWSConnectionState.ts @@ -5,7 +5,6 @@ import type { NetworkConnectionState, WSConnectionConfig, WSConnectionState } fr import { useChatContext } from '../../../contexts/chatContext/ChatContext'; -const identity = (state: WSConnectionState) => state; const healthSelector = (state: WSConnectionState) => ({ isHealthy: state.isHealthy, lastHealthyAt: state.lastHealthyAt, @@ -29,7 +28,7 @@ const networkSelector = (state: NetworkConnectionState) => ({ isOnline: state.is */ export const useWSConnectionState = () => { const { client } = useChatContext(); - return useStateStore(client?.wsConnection?.state, identity); + return useStateStore(client?.wsConnection?.state); }; /** diff --git a/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx b/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx index 47159673a7..7fb7cf9e82 100644 --- a/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx +++ b/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; import { useStateStore } from '@stream-io/state-store/react-bindings'; -import type { EditingAuditState, MessageComposerState } from 'stream-chat'; +import type { MessageComposerState } from 'stream-chat'; import { CORE_NOTIFICATION_TYPE, ScheduledMessageBlockReason } from 'stream-chat'; import { useEditedScheduledMessage } from './hooks/useEditedScheduledMessage'; @@ -15,8 +15,6 @@ const quotedMessageSelector = (state: MessageComposerState) => ({ quotedMessage: state.quotedMessage, }); -const editingAuditSelector = (state: EditingAuditState) => state; - /** * The save button while the composer edits a scheduled message. Save is disabled while the message * can't be scheduled or quotes a deleted message, and a toast says so when a command is the reason. @@ -27,7 +25,7 @@ export const ScheduledMessageSaveButton = () => { const { quotedMessage } = useStateStore(messageComposer.state, quotedMessageSelector); // The block reason and the empty check read the composition, so this re-renders on every change // to it. The parent's re-render isn't enough: React Compiler caches this element (it has no props). - useStateStore(messageComposer.editingAuditState, editingAuditSelector); + useStateStore(messageComposer.editingAuditState); const { scheduleBlockReason } = messageComposer; const blockedByCommand = scheduleBlockReason === ScheduledMessageBlockReason.Command; diff --git a/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts b/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts index 48874e6765..54cc2b9901 100644 --- a/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts +++ b/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts @@ -1,14 +1,11 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; -import type { EditingAuditState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; import { pendingUploadsEnabledSelector } from './usePendingUploadsEnabled'; -const editingAuditStateStateSelector = (state: EditingAuditState) => state; - export const useMessageComposerHasSendableData = () => { const messageComposer = useMessageComposer(); - useStateStore(messageComposer.editingAuditState, editingAuditStateStateSelector); + useStateStore(messageComposer.editingAuditState); // `hasSendableData` also depends on whether pending uploads may be sent, which is composer config // rather than composer state, so toggling `attachments.pendingUploadsEnabled` re-renders too. useStateStore(messageComposer.configState, pendingUploadsEnabledSelector); diff --git a/package/src/hooks/useAttachmentPickerState.ts b/package/src/hooks/useAttachmentPickerState.ts index bf11d665cc..d18766d4d4 100644 --- a/package/src/hooks/useAttachmentPickerState.ts +++ b/package/src/hooks/useAttachmentPickerState.ts @@ -1,13 +1,8 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; import { useAttachmentPickerContext } from '../contexts/attachmentPickerContext/AttachmentPickerContext'; -import { AttachmentPickerState } from '../state-store/attachment-picker-store'; - -const selector = (nextState: AttachmentPickerState) => ({ - selectedPicker: nextState.selectedPicker, -}); export const useAttachmentPickerState = () => { const { attachmentPickerStore } = useAttachmentPickerContext(); - return useStateStore(attachmentPickerStore.state, selector); + return useStateStore(attachmentPickerStore.state); }; From 83148746bdbf651c56ffaa5e94232cbe8d699405 Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj Date: Thu, 3 Dec 2026 16:47:01 +0100 Subject: [PATCH 3/3] revert(store): restore explicit useStateStore selectors This reverts commit 0823c756e89b9fb1575d6fcb2dd28488747fedd5. State reads stay declared at the call site: every useStateStore call passes a selector naming the fields it reads, and an explicit identity selector where the whole state is needed. The selector-less form also widened useAttachmentPickerState and useBottomSheetState to re-render on every change to their stores. AGENTS.md now records the rule. --- AGENTS.md | 4 +++- .../store/bottom-sheet/useBottomSheetState.ts | 9 +++++++-- .../components/Channel/hooks/useSupersededChannelSwap.ts | 5 +++-- .../components/Chat/hooks/useNetworkConnectionState.ts | 4 +++- .../src/components/Chat/hooks/useWSConnectionState.ts | 3 ++- .../ScheduledMessages/ScheduledMessageSaveButton.tsx | 6 ++++-- .../hooks/useMessageComposerHasSendableData.ts | 5 ++++- package/src/hooks/useAttachmentPickerState.ts | 7 ++++++- 8 files changed, 32 insertions(+), 11 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index f93074d868..2afac23f5f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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. @@ -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. diff --git a/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts b/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts index a5ad3d54b6..2d5f57ac4d 100644 --- a/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts +++ b/package/src/ai-components/store/bottom-sheet/useBottomSheetState.ts @@ -1,5 +1,10 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; -import { sheetStore } from './store'; +import { type BottomSheetState, sheetStore } from './store'; -export const useBottomSheetState = () => useStateStore(sheetStore); +const selector = ({ open, height }: BottomSheetState) => ({ + open, + height, +}); + +export const useBottomSheetState = () => useStateStore(sheetStore, selector); diff --git a/package/src/components/Channel/hooks/useSupersededChannelSwap.ts b/package/src/components/Channel/hooks/useSupersededChannelSwap.ts index 7334cbf055..bfe761a494 100644 --- a/package/src/components/Channel/hooks/useSupersededChannelSwap.ts +++ b/package/src/components/Channel/hooks/useSupersededChannelSwap.ts @@ -1,8 +1,9 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; -import type { Channel, ChannelStateData } from 'stream-chat'; +import type { Channel, ChannelStateData, EditingAuditState } from 'stream-chat'; const supersededBySelector = ({ supersededBy }: ChannelStateData) => ({ supersededBy }); const activeSelector = ({ active }: ChannelStateData) => ({ active }); +const editingAuditStateSelector = (state: EditingAuditState) => state; /** * The instance `` renders: the one that superseded `channel`, which receives the events @@ -18,7 +19,7 @@ export const useSupersededChannelSwap = ( const { supersededBy } = useStateStore(channel?.state, supersededBySelector) ?? {}; const successorActive = useStateStore(supersededBy?.state, activeSelector)?.active ?? false; // Re-renders on every composer change so the emptiness read below stays current. - useStateStore(channel?.messageComposer.editingAuditState); + useStateStore(channel?.messageComposer.editingAuditState, editingAuditStateSelector); const composerIsEmpty = channel?.messageComposer.compositionIsEmpty ?? true; if (!supersededBy || (successorActive && !composerIsEmpty)) return channel; diff --git a/package/src/components/Chat/hooks/useNetworkConnectionState.ts b/package/src/components/Chat/hooks/useNetworkConnectionState.ts index cb6b3a4451..243e5c5b69 100644 --- a/package/src/components/Chat/hooks/useNetworkConnectionState.ts +++ b/package/src/components/Chat/hooks/useNetworkConnectionState.ts @@ -3,6 +3,8 @@ import type { NetworkConnectionState } from 'stream-chat'; import { useChatContext } from '../../../contexts/chatContext/ChatContext'; +const identity = (state: NetworkConnectionState) => state; + /** * The device's network status, as reported by the NetInfo listener `` registers on * `client.networkConnection`. Unlike {@link useWSConnectionState}, it is not affected by the socket @@ -17,7 +19,7 @@ import { useChatContext } from '../../../contexts/chatContext/ChatContext'; */ export const useNetworkConnectionState = () => { const { client } = useChatContext(); - return useStateStore(client?.networkConnection?.state); + return useStateStore(client?.networkConnection?.state, identity); }; /** diff --git a/package/src/components/Chat/hooks/useWSConnectionState.ts b/package/src/components/Chat/hooks/useWSConnectionState.ts index f6cefa2f0c..607e8ac968 100644 --- a/package/src/components/Chat/hooks/useWSConnectionState.ts +++ b/package/src/components/Chat/hooks/useWSConnectionState.ts @@ -5,6 +5,7 @@ import type { NetworkConnectionState, WSConnectionConfig, WSConnectionState } fr import { useChatContext } from '../../../contexts/chatContext/ChatContext'; +const identity = (state: WSConnectionState) => state; const healthSelector = (state: WSConnectionState) => ({ isHealthy: state.isHealthy, lastHealthyAt: state.lastHealthyAt, @@ -28,7 +29,7 @@ const networkSelector = (state: NetworkConnectionState) => ({ isOnline: state.is */ export const useWSConnectionState = () => { const { client } = useChatContext(); - return useStateStore(client?.wsConnection?.state); + return useStateStore(client?.wsConnection?.state, identity); }; /** diff --git a/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx b/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx index 7fb7cf9e82..47159673a7 100644 --- a/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx +++ b/package/src/components/ScheduledMessages/ScheduledMessageSaveButton.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from 'react'; import { useStateStore } from '@stream-io/state-store/react-bindings'; -import type { MessageComposerState } from 'stream-chat'; +import type { EditingAuditState, MessageComposerState } from 'stream-chat'; import { CORE_NOTIFICATION_TYPE, ScheduledMessageBlockReason } from 'stream-chat'; import { useEditedScheduledMessage } from './hooks/useEditedScheduledMessage'; @@ -15,6 +15,8 @@ const quotedMessageSelector = (state: MessageComposerState) => ({ quotedMessage: state.quotedMessage, }); +const editingAuditSelector = (state: EditingAuditState) => state; + /** * The save button while the composer edits a scheduled message. Save is disabled while the message * can't be scheduled or quotes a deleted message, and a toast says so when a command is the reason. @@ -25,7 +27,7 @@ export const ScheduledMessageSaveButton = () => { const { quotedMessage } = useStateStore(messageComposer.state, quotedMessageSelector); // The block reason and the empty check read the composition, so this re-renders on every change // to it. The parent's re-render isn't enough: React Compiler caches this element (it has no props). - useStateStore(messageComposer.editingAuditState); + useStateStore(messageComposer.editingAuditState, editingAuditSelector); const { scheduleBlockReason } = messageComposer; const blockedByCommand = scheduleBlockReason === ScheduledMessageBlockReason.Command; diff --git a/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts b/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts index 54cc2b9901..48874e6765 100644 --- a/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts +++ b/package/src/contexts/messageInputContext/hooks/useMessageComposerHasSendableData.ts @@ -1,11 +1,14 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; +import type { EditingAuditState } from 'stream-chat'; import { useMessageComposer } from './useMessageComposer'; import { pendingUploadsEnabledSelector } from './usePendingUploadsEnabled'; +const editingAuditStateStateSelector = (state: EditingAuditState) => state; + export const useMessageComposerHasSendableData = () => { const messageComposer = useMessageComposer(); - useStateStore(messageComposer.editingAuditState); + useStateStore(messageComposer.editingAuditState, editingAuditStateStateSelector); // `hasSendableData` also depends on whether pending uploads may be sent, which is composer config // rather than composer state, so toggling `attachments.pendingUploadsEnabled` re-renders too. useStateStore(messageComposer.configState, pendingUploadsEnabledSelector); diff --git a/package/src/hooks/useAttachmentPickerState.ts b/package/src/hooks/useAttachmentPickerState.ts index d18766d4d4..bf11d665cc 100644 --- a/package/src/hooks/useAttachmentPickerState.ts +++ b/package/src/hooks/useAttachmentPickerState.ts @@ -1,8 +1,13 @@ import { useStateStore } from '@stream-io/state-store/react-bindings'; import { useAttachmentPickerContext } from '../contexts/attachmentPickerContext/AttachmentPickerContext'; +import { AttachmentPickerState } from '../state-store/attachment-picker-store'; + +const selector = (nextState: AttachmentPickerState) => ({ + selectedPicker: nextState.selectedPicker, +}); export const useAttachmentPickerState = () => { const { attachmentPickerStore } = useAttachmentPickerContext(); - return useStateStore(attachmentPickerStore.state); + return useStateStore(attachmentPickerStore.state, selector); };