react-responsive-carousel icon indicating copy to clipboard operation
react-responsive-carousel copied to clipboard

Typescript error

Open kiri4eb opened this issue 3 years ago • 14 comments

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.

kiri4eb avatar Aug 06 '21 15:08 kiri4eb

Also seeing this error when I switched to PNP on Yarn 2

mckinnsb avatar Aug 09 '21 18:08 mckinnsb

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

mckinnsb avatar Aug 09 '21 20:08 mckinnsb

(This is on 3.2.20)

mckinnsb avatar Aug 09 '21 20:08 mckinnsb

These are present on CarouselProps but for some reason are not being evaluated correctly

mckinnsb avatar Aug 09 '21 20:08 mckinnsb

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

kiri4eb avatar Aug 09 '21 20:08 kiri4eb

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?

mckinnsb avatar Aug 09 '21 20:08 mckinnsb

@Kirill20123 not sure if I understood you; what was the workaround here?

mckinnsb avatar Aug 09 '21 22:08 mckinnsb

I have been experiencing this same issue and still have no resolution on it yet. Please HELP!!

Sanmi-Aina avatar Aug 13 '21 08:08 Sanmi-Aina

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?

Sanmi-Aina avatar Aug 13 '21 08:08 Sanmi-Aina

@FIlS-5 no i haven't

kiri4eb avatar Aug 13 '21 11:08 kiri4eb

@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

kiri4eb avatar Aug 13 '21 11:08 kiri4eb

Having the same issue on my project, a fix coming ?

bosteelsd avatar Nov 30 '21 10:11 bosteelsd

Having the same issue on my project, a fix coming ?

import { Carousel } from 'react-responsive-carousel/lib/js'

Try this import

kiri4eb avatar Nov 30 '21 10:11 kiri4eb

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/**"
  ]
}
...

shennan avatar Apr 06 '22 13:04 shennan

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.

stale[bot] avatar Oct 04 '22 04:10 stale[bot]