davidesp
davidesp

Reputation: 3962

Error: [ts] Cannot find name 'React

For some specific reasons I need to customize a bit the Ionic component: range, changing the component class name from Range to CustomRange (with selector: custom-range):

https://github.com/ionic-team/ionic/blob/master/core/src/components/range/range.tsx

for that I copy/pasted the files on:

https://github.com/ionic-team/ionic/tree/master/core/src/components/range

inside the directory:

/src/components/custom-range

Then I imported the module: CustomRange into the declarations on file: app.module.ts.

Also fixed the references on the import statements inside file: range.tsx which are fine.

But my problem is that I'm getting errors like:

[ts] Cannot find name 'React'.
(property) JSX.IntrinsicElements.slot: JSXElements.SlotAttributes

as you can see on the following image:

enter image description here

Do you have any idea on how can I workaround this?

Thanks!

Upvotes: 1

Views: 6438

Answers (1)

Matt McCutchen
Matt McCutchen

Reputation: 30919

Looks like you need to have these settings in your tsconfig.json if you want to use JSX with Ionic:

"jsx": "react",
"jsxFactory": "h",

Then as long as you are importing something from @stencil/core, you should get the global declaration of h, so you should be set.

Upvotes: 1

Related Questions