mirror of
https://github.com/r-freeman/portfolio.git
synced 2025-04-19 12:24:46 +00:00
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m16s
19 lines
602 B
TypeScript
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>
|
|
)
|
|
} |