import {createContext, ReactNode, RefObject, useContext, useRef} from 'react' type CommentFormContext = { commentFormRef?: RefObject focusCommentForm: () => void } export const CommentFormContext = createContext(null) export const useCommentFormContext = () => useContext(CommentFormContext) export default function CommentFormProvider({children}: { children: ReactNode }) { const commentFormRef = useRef(null) const focusCommentForm = () => { commentFormRef.current?.focus() } return ( {children} ) }