-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'ReCAPTCHA' cannot be used as a JSX component. #277
Comments
Same error |
same error |
Caused by latest version of In my case reverting to last known working state |
I found the same issue and applied the following workaround that fixed it: https://stackoverflow.com/a/75093164 |
Same error! @types/react": "18.2.37 |
Same problem here in Remix 2.3.1 and TSX:
Looks like it doesn't even injects google recaptcha script element to DOM. |
Note: this one doesn't work for Remix 2.3.1 |
Same here, tried installing @types/react-google-recaptcha but that didnt help |
Switched to |
adding this to my tsconfig compiler options seems to have fixed the issue for now. "paths": { |
@127 |
@eeshankeni |
yes, as recommended switched to "@google-recaptcha/react": "^1.0.1", |
Does anyone figured out a solution without downgrading the react types? Adding the paths in config does not help as well |
is this package abandoned? |
Looks like |
I fixed my issue by removing the |
Hi, I managed to "solve" it by writing the typing locally. react-google-recaptcha.d.tsdeclare module "react-google-recaptcha" {
import * as React from "react";
interface ReCAPTCHAProps {
sitekey: string;
onChange?: (token: string | null) => void;
grecaptcha?: object;
theme?: "light" | "dark";
type?: "image" | "audio";
tabindex?: number;
onExpired?: () => void;
asyncScriptOnLoad?: () => void;
onErrored?: () => void;
stoken?: string;
hl?: string;
size?: "compact" | "normal" | "invisible";
badge?: "bottomright" | "bottomleft" | "inline";
isolated?: boolean;
}
class ReCAPTCHA extends React.Component<ReCAPTCHAProps> {
reset(): void;
execute(): void;
executeAsync(): Promise<string | null>;
getValue(): string | null;
getWidgetId(): number | null;
}
export default ReCAPTCHA;
} |
I'm using with next.js v15, it works for me. |
add to the tsconfig.jsonthis will fix the issue
|
react-google-recaptcha version: 2.1.0
react-async-script version: Y.Y.Y
Type error: 'ReCAPTCHA' cannot be used as a JSX component.
Its instance type 'ReCAPTCHA' is not a valid JSX element.
The types returned by 'render()' are incompatible between these types.
Type 'import("/app/node_modules/@types/react-dom/node_modules/@types/react/ts5.0/index").ReactNode' is not assignable to type 'React.ReactNode'.
Type 'ReactElement<any, string | JSXElementConstructor>' is not assignable to type 'ReactNode'.
Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor>' but required in type 'ReactPortal'.
The text was updated successfully, but these errors were encountered: