denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.67k stars 654 forks source link

Can not use react-select #2595

Open hemedani opened 4 months ago

hemedani commented 4 months ago

Throw this error when use react-select library even with npm or esm.sh

Invalid type passed to createElement(): [object Object]

Error: Invalid type passed to createElement(): [object Object]
    at a.__b (https://esm.sh/stable/preact@10.19.6/denonext/debug.js:23:9)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2611)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2543)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:5050)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:2543)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:5050)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:5050)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string.mjs:2:3802)
    at m (https://esm.sh/v135/preact-render-to-string@6.3.1/X-ZS8q/denonext/preact-render-to-string

And this is the LSP Diagnostic error message

'Select' cannot be used as a JSX component.
  Its type 'StateManagedSelect' is not a valid JSX element type.
    Type 'StateManagedSelect' is not assignable to type 'FunctionComponent<any>'.
      Call signature return types 'ReactElement<any, string | JSXElementConstructor<any>>' and 'VNode<any> | null' are incompatible.
        The types of 'type' are incompatible between these types.
          Type 'string | JSXElementConstructor<any>' is not assignable to type 'string | ComponentType<any>'.
            Type '(props: any, deprecatedLegacyContext?: any) => ReactNode' is not assignable to type 'string | ComponentType<any>'.
              Type '(props: any, deprecatedLegacyContext?: any) => ReactNode' is not assignable to type 'FunctionComponent<any>'.
                Type 'ReactNode' is not assignable to type 'VNode<any> | null'.
                  Type 'undefined' is not assignable to type 'VNode<any> | null'.
CAYdenberg commented 4 months ago

You'll have to set up preact-compat to use React libraries ... you can give some of the approaches here a shot: https://github.com/denoland/fresh/discussions/432