Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit fe9e739

Browse files
authored
Merge pull request #3 from siberiacancode/#1
#1 into main ☄ add token to callback
2 parents 50ef8d1 + f71cb7e commit fe9e739

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

.eslintrc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ module.exports = {
1010
'@typescript-eslint/no-unsafe-assignment': 'off',
1111
'@typescript-eslint/no-unsafe-member-access': 'off',
1212
'@typescript-eslint/no-unsafe-argument': 'off',
13-
'@typescript-eslint/no-namespace': 'off'
13+
'@typescript-eslint/no-namespace': 'off',
14+
'@typescript-eslint/no-floating-promises': 'off',
15+
'@typescript-eslint/await-thenable': 'off',
16+
'@typescript-eslint/no-unsafe-call': 'off',
17+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
18+
'@typescript-eslint/no-var-requires': 'off',
19+
'no-restricted-syntax': 'off',
20+
'promise/always-return': 'off'
1421
}
1522
}
1623
]

src/components/GoogleReCaptchaCheckbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface GoogleReCaptchaCheckboxProps extends Omit<ComponentProps<'div'>
1010
action?: string;
1111
className?: string;
1212
container?: ContainerId | HTMLElement;
13-
callback?: () => void;
13+
callback?: (token: string) => void;
1414
errorCallback?: () => void;
1515
expiredCallback?: () => void;
1616
language?: GoogleReCaptcha.Language;

src/context/GoogleReCaptchaContext.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,28 @@ export interface GoogleReCaptchaContextProps {
1818
) => void;
1919
}
2020

21+
const contextError =
22+
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider';
23+
2124
export const GoogleReCaptchaContext = createContext<GoogleReCaptchaContextProps>({
2225
googleReCaptcha: {},
2326
siteKey: '',
2427
language: '',
2528
isLoading: true,
2629
executeV3: () => {
27-
throw Error(
28-
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
29-
);
30+
throw Error(contextError);
3031
},
3132
executeV2Invisible: () => {
32-
throw Error(
33-
'GoogleReCaptchaContext has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
34-
);
33+
throw Error(contextError);
3534
},
3635
reset: () => {
37-
throw Error(
38-
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
39-
);
36+
throw Error(contextError);
4037
},
4138
getResponse: () => {
42-
throw Error(
43-
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
44-
);
39+
throw Error(contextError);
4540
},
4641
render: () => {
47-
throw Error(
48-
'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'
49-
);
42+
throw Error(contextError);
5043
}
5144
});
5245

src/context/GoogleReCaptchaProvider.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { render } from '@testing-library/react';
21
import React from 'react';
2+
import { render } from '@testing-library/react';
33

44
import type { GoogleReCaptchaProviderProps } from './GoogleReCaptchaProvider';
55
import { GoogleReCaptchaProvider } from './GoogleReCaptchaProvider';

src/context/GoogleReCaptchaProvider.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
22

3-
import type { GoogleReCaptcha, ContainerId } from '../utils';
3+
import type { ContainerId, GoogleReCaptcha } from '../utils';
44
import {
5-
removeGoogleReCaptchaScript,
6-
injectGoogleReCaptchaScript,
5+
checkGoogleReCaptchaInjected,
76
hideGoogleReCaptchaBadge,
8-
removeGoogleReCaptchaContainer,
7+
injectGoogleReCaptchaScript,
98
removeGoogleReCaptchaBadge,
10-
checkGoogleReCaptchaInjected
9+
removeGoogleReCaptchaContainer,
10+
removeGoogleReCaptchaScript
1111
} from '../utils';
1212

1313
import { GoogleReCaptchaContextProvider } from './GoogleReCaptchaContext';

src/context/withGoogleReCaptcha.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface WithGoogleReCaptchaParams {
77
googleReCaptcha: GoogleReCaptchaContextProps;
88
}
99

10-
export const withGoogleReCaptcha = <OwnProps extends unknown>(
10+
export const withGoogleReCaptcha = <OwnProps,>(
1111
Component: React.ComponentType<OwnProps & WithGoogleReCaptchaParams>
1212
) => {
1313
const WithGoogleReCaptchaComponent = (props: OwnProps & Partial<WithGoogleReCaptchaParams>) => (

0 commit comments

Comments
 (0)