Skip to content

Commit 11f2c57

Browse files
committed
refactor(emojis): drop componentName args from context hook calls
Remove the `componentName` label argument from the picker's context hook calls across the emoji plugin (`useEmojiPickerContext`, `useEmojiPickerPreviewContext`, and the core `useTranslationContext` / `useMessageComposer*` hooks). `useEmojiPickerContext` and `useEmojiPickerPreviewContext` are now zero-param and throw a single generic "must be rendered within a StreamEmojiPicker.Root" error.
1 parent fdce557 commit 11f2c57

11 files changed

Lines changed: 17 additions & 18 deletions

src/plugins/Emojis/EmojiPicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ const classNames: Pick<
5757
* packages. See the emoji section of `AI.md` for migration notes.
5858
*/
5959
export const EmojiPicker = (props: EmojiPickerProps) => {
60-
const { t } = useTranslationContext('EmojiPicker');
61-
const { textareaRef } = useMessageComposerContext('EmojiPicker');
60+
const { t } = useTranslationContext();
61+
const { textareaRef } = useMessageComposerContext();
6262
const { textComposer } = useMessageComposerController();
6363
const isCooldownActive = useIsCooldownActive();
6464
const [displayPicker, setDisplayPicker] = useState(false);

src/plugins/Emojis/StreamEmojiPicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const classNames: Pick<
6868
};
6969

7070
const StreamEmojiPickerComponent = (props: StreamEmojiPickerProps) => {
71-
const { t } = useTranslationContext('EmojiPicker');
72-
const { textareaRef } = useMessageComposerContext('EmojiPicker');
71+
const { t } = useTranslationContext();
72+
const { textareaRef } = useMessageComposerContext();
7373
const { textComposer } = useMessageComposerController();
7474
const isCooldownActive = useIsCooldownActive();
7575
// Skin tone and frequently-used live here (not in the panel) so they survive the

src/plugins/Emojis/components/CategoryNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const NAV_KEYS = ['ArrowRight', 'ArrowLeft', 'Home', 'End'];
1414
*/
1515
export const CategoryNav = () => {
1616
const { activeCategoryId, categories, isSearching, requestScrollToCategory } =
17-
useEmojiPickerContext('CategoryNav');
17+
useEmojiPickerContext();
1818
const navRef = useRef<HTMLDivElement>(null);
1919
const active = isSearching ? undefined : activeCategoryId;
2020
const rovingId = active ?? categories[0]?.id;

src/plugins/Emojis/components/EmojiButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type EmojiButtonProps = {
1212
* skin tone. Memoized because the grid can render ~1800 of these.
1313
*/
1414
export const EmojiButton = memo(function EmojiButton({ emoji }: EmojiButtonProps) {
15-
const { resolveNative, selectEmoji } = useEmojiPickerContext('EmojiButton');
15+
const { resolveNative, selectEmoji } = useEmojiPickerContext();
1616
const { setPreviewedEmoji } = useEmojiPickerPreviewContext();
1717

1818
return (

src/plugins/Emojis/components/EmojiGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const CategorySection = ({ category }: { category: EmojiPickerCategory }) => (
3939
*/
4040
export const EmojiGrid = () => {
4141
const { categories, isSearching, scrollTarget, searchResults, setActiveCategory } =
42-
useEmojiPickerContext('EmojiGrid');
42+
useEmojiPickerContext();
4343
const virtuosoRef = useRef<VirtuosoHandle>(null);
4444
const atBottomRef = useRef(false);
4545
const bodyRef = useRef<HTMLDivElement>(null);

src/plugins/Emojis/components/EmojiPickerRoot.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const EmojiPickerRoot = ({
101101
style,
102102
theme,
103103
}: EmojiPickerRootProps) => {
104-
const { t } = useTranslationContext('EmojiPickerRoot');
104+
const { t } = useTranslationContext();
105105
const { data, error, retry } = useEmojiPickerState();
106106
const status: 'error' | 'loading' | 'ready' = data
107107
? 'ready'

src/plugins/Emojis/components/EmptyResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type EmptyResultsProps = {
99
* Shown in place of the emoji grid when a search yields no matches.
1010
*/
1111
export const EmptyResults = ({ emoji }: EmptyResultsProps) => {
12-
const { t } = useTranslationContext('EmojiPicker');
12+
const { t } = useTranslationContext();
1313

1414
return (
1515
<div className='str-chat__emoji-picker__empty' role='status'>

src/plugins/Emojis/components/PreviewPane.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { useTranslationContext } from '../../../context';
1010
* so hovering does not re-render the emoji grid).
1111
*/
1212
export const PreviewPane = () => {
13-
const { t } = useTranslationContext('EmojiPickerPreview');
14-
const { resolveNative } = useEmojiPickerContext('PreviewPane');
13+
const { t } = useTranslationContext();
14+
const { resolveNative } = useEmojiPickerContext();
1515
const { previewedEmoji } = useEmojiPickerPreviewContext();
1616

1717
return (

src/plugins/Emojis/components/SearchInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export type SearchInputProps = {
1616
* enclosing picker dialog (the default grid's DOM contract).
1717
*/
1818
export const SearchInput = ({ autoFocus = true }: SearchInputProps) => {
19-
const { t } = useTranslationContext('EmojiPickerSearchInput');
20-
const { query, setQuery } = useEmojiPickerContext('SearchInput');
19+
const { t } = useTranslationContext();
20+
const { query, setQuery } = useEmojiPickerContext();
2121
const inputId = useStableId();
2222
const inputRef = useRef<HTMLInputElement>(null);
2323

src/plugins/Emojis/components/SkinToneSelector.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const ARROW_KEYS = ['ArrowRight', 'ArrowLeft', 'ArrowDown', 'ArrowUp', 'Home', '
1414
* `setSkinTone`.
1515
*/
1616
export const SkinToneSelector = () => {
17-
const { t } = useTranslationContext('EmojiPickerSkinTone');
18-
const { setSkinTone, skinToneIndex, skinTones } =
19-
useEmojiPickerContext('SkinToneSelector');
17+
const { t } = useTranslationContext();
18+
const { setSkinTone, skinToneIndex, skinTones } = useEmojiPickerContext();
2019
const maxIndex = skinTones.length - 1;
2120
const [expanded, setExpanded] = useState(false);
2221
const toggleRef = useRef<HTMLButtonElement>(null);

0 commit comments

Comments
 (0)