/
githubmirror
/
novu
Обзор
Документация
Войти
/
githubmirror
/
novu
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
next
packages/react/src/components/subscription/DefaultSubscription.tsx
41 строка
1 KB
Paweł Tymczuk
chore(js,react,nextjs,api-service): polishing for full topic subscription creation flow (#9573)
09 дек 2025, 18:53
Не верифицирован
09 дек 2025, 18:53
9617a81
Код
Авторство
О чём код?
import { TopicSubscription } from '@novu/js'; import { SubscriptionProps } from '@novu/js/ui'; import { useCallback } from 'react'; import { useNovuUI } from '../../context/NovuUIContext'; import { useRenderer } from '../../context/RendererContext'; import { Mounter } from '../Mounter'; export type PreferencesRenderer = (subscription?: TopicSubscription, loading?: boolean) => React.ReactNode; export type DefaultSubscriptionProps = { renderPreferences?: PreferencesRenderer; } & Pick<SubscriptionProps, 'open' | 'placement' | 'placementOffset' | 'topicKey' | 'identifier' | 'preferences'>; export const DefaultSubscription = (props: DefaultSubscriptionProps) => { const { topicKey, identifier, preferences, open, placement, placementOffset, renderPreferences } = props; const { novuUI } = useNovuUI(); const { mountElement } = useRenderer(); const mount = useCallback( (element: HTMLElement) => { return novuUI.mountComponent({ name: 'Subscription', props: { topicKey, identifier, preferences, open, placementOffset, placement, renderPreferences: renderPreferences ? (el, subscription, loading) => mountElement(el, renderPreferences(subscription, loading)) : undefined, }, element, }); }, [topicKey, identifier, preferences, open, placementOffset, placement, renderPreferences, novuUI, mountElement] ); return <Mounter mount={mount} />; };