import React, { createContext, PropsWithChildren, useContext, useMemo } from 'react' interface ConversationContextValue { conversationId: number currentPageReplyRootId: string | null } interface ConversationContextProviderProps extends PropsWithChildren { conversationId: number currentPageReplyRootId: string | null } const ConversationContext = createContext({ conversationId: 0, currentPageReplyRootId: null, }) export const ConversationContextProvider = ({ children, conversationId, currentPageReplyRootId, }: ConversationContextProviderProps) => { const value = useMemo( () => ({ conversationId, currentPageReplyRootId, }), [conversationId, currentPageReplyRootId] ) return {children} } export const useConversationContext = () => useContext(ConversationContext)