saleor-dashboard/src/components/Shop/index.tsx

21 lines
567 B
TypeScript
Raw Normal View History

2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
import { TypedShopInfoQuery } from "./query";
import { ShopInfo_shop } from "./types/ShopInfo";
type ShopContext = ShopInfo_shop;
export const shopContext = React.createContext<ShopContext>(undefined);
export const ShopProvider: React.StatelessComponent<{}> = ({ children }) => (
<TypedShopInfoQuery>
{({ data }) => (
<shopContext.Provider value={data ? data.shop : undefined}>
{children}
</shopContext.Provider>
)}
</TypedShopInfoQuery>
);
export const Shop = shopContext.Consumer;
export default Shop;