react-responsive-carousel
react-responsive-carousel copied to clipboard
Typescript error
TS2607: JSX element class does not support attributes because it does not have a 'props' property. TS2786: 'Carousel' cannot be used as a JSX component. Its instance type 'Carousel' is not a valid JSX element. Type 'Carousel' is missing the following properties from type 'ElementClass': context, setState, forceUpdate, props, and 2 more.
Also seeing this error when I switched to PNP on Yarn 2
Yeah; I just did a cursory review of the index.d.ts
file produced for Carousel, and it's not just missing elements from ElementClass
, it's also missing definitions for a lot of the public interface; examples include showArrows/showThumbs/showStatus
(This is on 3.2.20)
These are present on CarouselProps
but for some reason are not being evaluated correctly
I think there is a mistake in export interface or type in index.d.ts. I disabled the error by importing from carousel/js sorry i'm writing from phone
JSX element class does not support attributes because it does not have a 'props' property.
I'm guessing it has something to do with this?
@Kirill20123 not sure if I understood you; what was the workaround here?
I have been experiencing this same issue and still have no resolution on it yet. Please HELP!!
JSX element class does not support attributes because it does not have a 'props' property.
I'm guessing it has something to do with this?
Having the same issue; have you been able to rectify this?
@FIlS-5 no i haven't
@mckinnsb i dont have the right workaround, you can disable typescript error with importing carousel like this
import { Carousel } from 'react-responsive-carousel/lib/js'
but you won't be able to get typescript help
Having the same issue on my project, a fix coming ?
Having the same issue on my project, a fix coming ?
import { Carousel } from 'react-responsive-carousel/lib/js'
Try this import
This seems to happen for me when I'm in a Yarn workspace and add a "nohoist"
field to the root workspace package.json
.
This could just be my specific case but I get the error when I added React and ReactDOM as a "nohoist" package:
...
"workspaces": {
"packages": [
"some-folder",
"some-other-folder"
],
"nohoist": [
"**/react",
"**/react/**",
"**/react-dom",
"**/react-dom/**"
]
}
...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.