Skip to content

Instantly share code, notes, and snippets.

@datvtwkm
Last active August 26, 2018 07:06
Show Gist options
  • Save datvtwkm/3e88c9dd3e36be70f5a119a26ee31445 to your computer and use it in GitHub Desktop.
Save datvtwkm/3e88c9dd3e36be70f5a119a26ee31445 to your computer and use it in GitHub Desktop.
// @flow
import type { ComponentType } from 'react';
const containers = {};
export const setContainer = (newContainer: ComponentType<any>) => {
if (newContainer && newContainer.name) {
containers[newContainer.name] = newContainer;
return;
}
throw new Error('container has no name');
};
export const getContainer = (name: string) => containers[name];
export const removeContainer = (name: string) => { containers[name] = null; };
export default {
setContainer,
getContainer,
removeContainer
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment