ReactJS
1import React from "react";
2import {usePostsData} from "../../hooks/usePostsData";
3
4export interface IPostContextData {
5subreddit: string;
6title: string;
7thumbnail: string;
8author: string;
9score: number;
10created: Date;
11id: string;
12}
13export const postsContext = React.createContext<IPostContextData[]>([]);
14
15export function PostsContextProvider({children} : {children: React.ReactNode}){
16const [postsData] = usePostsData();
17
18return (
19<postsContext.Provider value={postsData}>
20{children}
21</postsContext.Provider>
22);
23}