@hackplan/polaris
Version:
Shopify’s product component library
18 lines (17 loc) • 839 B
JavaScript
import { useContext } from 'react';
/* eslint-disable shopify/strict-component-boundaries */
import { AppProviderContext } from '../../components/AppProvider';
import { ThemeProviderContext } from '../../components/ThemeProvider';
/* eslint-enable shopify/strict-component-boundaries */
function usePolaris() {
const polaris = useContext(AppProviderContext);
if (Object.keys(polaris).length < 1) {
throw new Error(`The <AppProvider> component is required as of v2.0 of Polaris React. See
https://polaris.shopify.com/components/structure/app-provider for implementation
instructions.`);
}
const polarisTheme = useContext(ThemeProviderContext);
const polarisContext = Object.assign({}, polaris, { theme: polarisTheme });
return polarisContext;
}
export default usePolaris;