From 3b7e197864c8b731212cfafe4e673c5c486a264a Mon Sep 17 00:00:00 2001 From: Jakub Biesiada Date: Sun, 4 Apr 2021 17:15:54 +0200 Subject: [PATCH 1/2] chore: update config --- src/useShortenUrl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/useShortenUrl.ts b/src/useShortenUrl.ts index 6301990..2bccc2c 100644 --- a/src/useShortenUrl.ts +++ b/src/useShortenUrl.ts @@ -4,7 +4,7 @@ import { BitlyLink } from 'bitly/dist/types'; import { ShortenUrlContext } from './context'; -export const useShortenUrl = (url: string) => { +export const useShortenUrl = (url: string, {}: any) => { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [data, setData] = useState(); From 85eab71c76e41597204bf85d0c5fe837492d5b01 Mon Sep 17 00:00:00 2001 From: Jakub Biesiada Date: Mon, 21 Jun 2021 23:09:08 +0200 Subject: [PATCH 2/2] chore: update --- rollup.config.js | 4 ++-- src/context.tsx | 14 ++++++-------- src/useShortenUrl.ts | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 34c5b6f..a7978d8 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -20,7 +20,7 @@ export default { ], plugins: [resolve(), typescript(), terser()], external: [ - ...Object.keys(pkg.dependencies), - ...Object.keys(pkg.peerDependencies), + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), ], }; diff --git a/src/context.tsx b/src/context.tsx index 6cecc89..c46fac1 100644 --- a/src/context.tsx +++ b/src/context.tsx @@ -3,15 +3,11 @@ import { BitlyClient } from 'bitly'; import { BitlyConfig } from 'bitly/dist/types'; interface Config { - accessToken: string; - options?: BitlyConfig; + readonly accessToken: string; + readonly options?: BitlyConfig; } -export const ShortenUrlContext = React.createContext<{ - readonly bitly: BitlyClient; -}>({ - bitly: {} as BitlyClient, -}); +export const ShortenUrlContext = React.createContext({} as BitlyClient); ShortenUrlContext.displayName = 'ShortenUrlContext'; @@ -24,8 +20,10 @@ export const ShortenUrlProvider: React.FC<{ readonly config: Config }> = ({ const bitly = new BitlyClient(accessToken, options); return ( - + {children} ); }; + +ShortenUrlProvider.displayName = 'ShortenUrlProvider'; diff --git a/src/useShortenUrl.ts b/src/useShortenUrl.ts index 2bccc2c..71228c7 100644 --- a/src/useShortenUrl.ts +++ b/src/useShortenUrl.ts @@ -4,12 +4,12 @@ import { BitlyLink } from 'bitly/dist/types'; import { ShortenUrlContext } from './context'; -export const useShortenUrl = (url: string, {}: any) => { +export const useShortenUrl = (url: string) => { const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [data, setData] = useState(); - const { bitly } = useSafeContext(ShortenUrlContext); + const bitly = useSafeContext(ShortenUrlContext); useEffect(() => { const shorten = async () => {