import React , { createContext , useReducer } from "react" ; import { ListItemCommentsStateReducer } from "./ListItemCommentsStateReducer" ; import { IListItemCommentsState } from "./IListItemCommentsState" ; import { IListItemCommentsStateContext } from "./IListItemCommentsStateContext" ; import { IPageInfo } from "../../models/IPageInfo" ; import { IAddCommentPayload } from "../../models/IAddCommentPayload" ; import { IComment } from "../Comments/IComment" ; const initialState = { errorInfo : undefined , comments : [ ] , isLoading : false , isScrolling : false , pageInfo : { } as IPageInfo , commentAction : undefined , commentToAdd : { } as IAddCommentPayload , selectedComment : { } as IComment , } ; const stateInit = { listItemCommentsState : initialState , setlistItemCommentsState : ( { } ) => { return ; } , } ; export const ListItemCommentsStateContext = createContext < IListItemCommentsStateContext > ( stateInit ) ; export const ListItemCommentsStateProvider = ( props ) : JSX . Element => { const [ listItemCommentsState , setlistItemCommentsState ] = useReducer ( ListItemCommentsStateReducer , initialState ) ; return ( < ListItemCommentsStateContext . Provider value = { { listItemCommentsState , setlistItemCommentsState } } > { props . children } < /ListItemCommentsStateContext.Provider>); } ;