This example shows abstracts the way Apollo Client creates its Context components to avoid context duplication, you can see the Apollo original code here
The main idea is to give you the ability to share a React Context between packages and applications, like Microfrontends with Module Federation.
// global-context.ts
import * as React from "react";
export function getGlobalContext<P = {}>(