portfolio/app/context/ReplyProvider.tsx
Ryan Freeman 8cc62e5b78
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m16s
Extract providers for comment component
2025-04-08 22:05:01 +01:00

19 lines
602 B
TypeScript

import {createContext, ReactNode, useContext, useState} from 'react'
import type {Comment} from '@/types'
type ReplyContext = {
replyTo: Comment | null
setReplyTo: (replyTo: Comment | null) => void
}
export const ReplyContext = createContext<ReplyContext | null>(null)
export const useReplyContext = () => useContext(ReplyContext)
export default function ReplyProvider({children}: { children: ReactNode }) {
const [replyTo, setReplyTo] = useState<Comment | null>(null)
return (
<ReplyContext.Provider value={{replyTo, setReplyTo}}>{children}</ReplyContext.Provider>
)
}