refactor: move more header stuff to elements package

This commit is contained in:
Satyajit Sahoo
2021-02-04 15:07:22 +01:00
parent 07ba7a9687
commit 509ca49b64
22 changed files with 324 additions and 200 deletions

View File

@@ -0,0 +1,21 @@
import * as React from 'react';
const contexts = new Map<string, React.Context<any>>();
export default function getNamedContext<T>(
name: string,
initialValue: T
): React.Context<T> {
let context = contexts.get(name);
if (context) {
return context;
}
context = React.createContext<T>(initialValue);
context.displayName = name;
contexts.set(name, context);
return context;
}

View File

@@ -17,4 +17,6 @@ export { default as useLinkBuilder } from './useLinkBuilder';
export { default as ServerContainer } from './ServerContainer';
export { default as getNamedContext } from './getNamedContext';
export * from './types';