Not sure how to use 3rd party libraries with preact/compat
See original GitHub issue- Check if updating to the latest Preact version resolves the issue
Describe the bug
So I’m trying to get rid of @types/react
so that the code fully relies on preact
and preact/compat
. For some reason I get the following errors:
'ReactTooltip' cannot be used as a JSX component.
Its instance type 'ReactTooltip' is not a valid JSX element.
Type 'ReactTooltip' is missing the following properties from type 'Component<any, any>': state, props, context, setState, and 2 more.
JSX element class does not support attributes because it does not have a 'props' property.
I use vite as my bundler, which uses rollup. It starts fine without any issues with yarn start
, seems like only typescript is upset with this behavior (which in turn breaks the bundling with yarn build
).
It seems like most libraries work fine, except for these two. They are declared in node_modules
like class SimpleBar extends React.Component<SimpleBar.Props>
. Which should be fine as I’m using preact/compat
? Maybe my tsconfig is somehow messed up? I’m currently working in this repo: https://github.com/BigWhaleLabs/seal-cred-frontend — but it’s a bit tedious to set it up so I provide it here just as a reference to my config files.
I’m sure I’m doing something wrong but I can’t put my finger on it. Are there any extra steps to achieve react/compat
working with 3rd party components from npm except for modifying tsconfig as noted in here: https://preactjs.com/guide/v10/typescript?
To Reproduce Try using https://github.com/wwayne/react-tooltip or https://github.com/grsmto/simplebar.
Expected behavior No error should be shown?
Screenshots
Issue Analytics
- State:
- Created a year ago
- Comments:13 (9 by maintainers)
Top GitHub Comments
Created https://github.com/preactjs/preact-www/pull/850 for this.
No, it was not.
Hopefully it creates symlinks, else, you might need to work out with its maintainers how to best go about this.