In the project I'm creating a React Contex and I want to type properly the children, unfortunately in codesandbox only "any" type is accepted. Can You please look at it and suggest what type it should be ? I would like to avoid "any" type.
This is how Context.Provider is implemented
const App = () => {
return (
<BrowserRouter>
<PostsContextProvider>
<HeaderComponent />
<ButtonsNavigation />
<Routing />
</PostsContextProvider>
<DownBar />
</BrowserRouter>
);
};
export default App;
And here is the Context component
interface PostsContextValues {
posts: PostType[];
}
export const PostsContext = createContext<PostsContextValues>({
posts: []
});
export const PostsContextProvider = ({ children }: any) => {
const value = useMemo(
() => ({
posts: data
}),
[data]
);
return (
<PostsContext.Provider value={value}>{children}</PostsContext.Provider>
);
};
thanks !
PropsWithChildren
helper you can use. – Yabber