diff --git a/README.md b/README.md index 1e1a6861..d795de9b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ or yarn add next-data-hooks ``` -2. Add Provider to `_app` +2. Add Provider to `_app.tsx` or `_app.js` ```tsx import { AppProps } from 'next/app'; diff --git a/declarations.d.ts b/declarations.d.ts deleted file mode 100644 index c601d70f..00000000 --- a/declarations.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { GetStaticPropsContext } from 'next'; -declare type Unwrap = T extends Promise ? U : T; -/** - * Creates a data hook. - * - * @param key The key to uniquely identify this data hooks from other on the same page. - * @param getData An async for data that will be called via `getStaticProps` in next.js - * @return A hook that can be used in any component within the page's React tree - */ -declare function createDataHook(key: string, getData: (variables: GetStaticPropsContext) => R | Promise): (() => Unwrap) & { - getData: (variables: GetStaticPropsContext) => R | Promise; - key: string; -}; -export default createDataHook; - -import { GetStaticPropsContext } from 'next'; -import createDataHook from './create-data-hook'; -declare type DataHook = ReturnType; -/** - * Given an array of data hooks created with `createDataHooks`, this function - * returns a function that be used as a `getStaticProps` implementation. - * - * @param hooks an array of data hooks created with `createDataHooks` - * @return a `getStaticProps` implementation - */ -declare function createDataHooksProps(hooks: DataHook[]): (context: GetStaticPropsContext) => Promise<{ - props: { - nextDataHooks: any; - }; -}>; -export default createDataHooksProps; - -/// -interface NextDataHooksContextValue { - [key: string]: any; -} -/** - * React Context used by `next-data-hooks` to pull static data. - */ -declare const NextDataHooksContext: import("react").Context; -export default NextDataHooksContext; - -/// -/** - * Injects the data from data hooks into React Context. Place this in `_app` - */ -declare function NextDataHooksProvider({ nextDataHooks, children }: any): JSX.Element; -export default NextDataHooksProvider;