Skip to content
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

Issue with Types #267

Open
foufrix opened this issue Oct 19, 2023 · 0 comments
Open

Issue with Types #267

foufrix opened this issue Oct 19, 2023 · 0 comments

Comments

@foufrix
Copy link

foufrix commented Oct 19, 2023

Hi, I have everything working well, but as soon as I try to build i got this issue :

Type error: 'Reaptcha' cannot be used as a JSX component.
  Its instance type 'Reaptcha' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'string | number | boolean | ReactFragment | Element | null | undefined' is not assignable to type 'ReactNode'.
        Type 'ReactFragment' is not assignable to type 'ReactNode'.
          Type 'Iterable<React.ReactNode>' is not assignable to type 'Iterable<import("/Users/raf/Documents/PiNGS/discord-oauth/node_modules/@types/react-dom/node_modules/@types/react/index").ReactNode>'.
            Type 'React.ReactNode' is not assignable to type 'import("/Users/raf/Documents/PiNGS/discord-oauth/node_modules/@types/react-dom/node_modules/@types/react/index").ReactNode'.
              Type 'ReactElement<any, string | JSXElementConstructor<any>>' is not assignable to type 'ReactNode'.
                Property 'children' is missing in type 'ReactElement<any, string | JSXElementConstructor<any>>' but required in type 'ReactPortal'.

  38 |       <form>
  39 |         {isLoading && <Loader color="black" />}
> 40 |         <Reaptcha
     |          ^
  41 |           sitekey={RECAPTCHA_KEY}
  42 |           onVerify={(token) => onVerify(token)}
  43 |           onRender={() => setIsloading(false)}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I'm using NextJS.

I think the problem come from the definition of types here :

declare class Reaptcha extends Component<Props, State> {
    container?: HTMLDivElement | null;
    timer?: number | undefined;
    state: State;
    static defaultProps: Partial<Props>;
    static getDerivedStateFromProps(props: Props, state: State): {
        invisible: boolean;
    } | null;
    _isAvailable: () => boolean;
    _inject: () => void;
    _prepare: () => void;
    _renderRecaptcha: (container: HTMLDivElement, config: RecaptchaConfig) => number;
    _resetRecaptcha: () => void;
    _executeRecaptcha: () => void;
    _getResponseRecaptcha: () => string;
    _onVerify: (response: string) => void;
    _onExpire: () => void | undefined;
    _onError: () => void | undefined;
    _stopTimer: () => void;
    componentDidMount: () => void;
    componentDidUpdate(prevProps: Readonly<Props>): void;
    componentWillUnmount: () => void;
    renderExplicitly: () => Promise<void>;
    reset: () => Promise<void>;
    execute: () => Promise<void>;
    getResponse: () => Promise<string>;
    render: () => string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
}

changing it to

render: () => PromiseLikeOfReactNode

Allowed me to build with no issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant