diff --git a/package-lock.json b/package-lock.json index 5f24a55e..136163eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "next-data-hooks", - "version": "0.2.0", + "version": "0.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9a1f79b5..d2ea1775 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next-data-hooks", - "version": "0.2.0", + "version": "0.2.1", "description": "Use `getStaticProps` as react hooks", "private": true, "scripts": { diff --git a/src/create-data-hook.ts b/src/create-data-hook.ts index ce73bf98..734c83fe 100644 --- a/src/create-data-hook.ts +++ b/src/create-data-hook.ts @@ -2,8 +2,6 @@ import { useContext } from 'react'; import { GetStaticPropsContext } from 'next'; import NextDataHooksContext from './next-data-hooks-context'; -type Unwrap = T extends Promise ? U : T; - const stub = () => { throw new Error( 'Create data hook was run in the browser. See https://github.com/ricokahler/next-data-hooks#code-elimination' @@ -19,9 +17,9 @@ const stub = () => { */ function createDataHook( key: string, - getData: (variables: GetStaticPropsContext) => R | Promise + getData: (variables: GetStaticPropsContext) => Promise ) { - function useData(): Unwrap { + function useData(): R { const dataHooksContext = useContext(NextDataHooksContext); if (!dataHooksContext) { throw new Error(