Skip to content

Instantly share code, notes, and snippets.

@vman
Created February 2, 2020 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vman/c8bfbbca207a6b73eac2b4958e77ec7c to your computer and use it in GitHub Desktop.
Save vman/c8bfbbca207a6b73eac2b4958e77ec7c to your computer and use it in GitHub Desktop.
import * as React from 'react';
import { useContext } from 'react';
import { AppContext } from './AppContext';
//Infuse all components wrapped with this Higher Order Component with the serviceScope
export const withServiceScope = (Component: any) => {
return (props: any) => {
const appContext = useContext(AppContext);
return <Component serviceScope={appContext.serviceScope} {...props} />;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment