apexcharts.js icon indicating copy to clipboard operation
apexcharts.js copied to clipboard

ApexChart cannot be used as a JSX component

Open wonjin-dev opened this issue 2 years ago • 7 comments

Description

The graph is drawn normally, but an error message is output in macOS only

- 'ApexChart' cannot be used as a JSX component.
- Its instance type 'ReactApexChart' is not a valid JSX element.
- The types returned by 'render()' are incompatible between these types.
- Type 'React.ReactNode' is not assignable to type 'import("~/node_modules/@types/styled-components/node_modules/@types/react/index").ReactNode'.
- Type '{}' is not assignable to type 'ReactNode'.

Steps to Reproduce

  1. yarn(npm i) & yarn start (npm run start) in macOS

Expected Behavior

no error

Actual Behavior

drawn normally, but an error message is output

Screenshots

스크린샷 2022-04-10 오후 7 06 20

Reproduction Link

https://github.com/wonjin-dev/1coin/tree/master/src

wonjin-dev avatar Apr 10 '22 10:04 wonjin-dev

I also get this when trying to build via GitHub actions

OptimusOpus avatar Apr 10 '22 23:04 OptimusOpus

Look the error logs, I suspect that there is a conflict with Styled-components. i'd appreciate your advice

wonjin-dev avatar Apr 11 '22 00:04 wonjin-dev

I hadn't committed my yarn.lock, once I added that to GH the build worked fine and I didn't get this message

OptimusOpus avatar Apr 11 '22 06:04 OptimusOpus

I have same issue, but import path is little bit different.

Type 'React.ReactNode' is not assignable to type 'import("~/node_modules/@types/react-dom/node_modules/@types/react/index").ReactNode'.

full log is below

'ApexChart' cannot be used as a JSX component.
  Its instance type 'ReactApexChart' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'React.ReactNode' is not assignable to type 'import("~/node_modules/@types/react-dom/node_modules/@types/react/index").ReactNode'.
        Type '{}' is not assignable to type 'ReactNode'.

blingblin-g avatar Apr 13 '22 07:04 blingblin-g

I've just solved this problem with // @ts-ignore on the component <ApexChart /> like this below.

        // @ts-ignore
        <ApexChart
          type="line"

I think it has an issue with React v18 and TypeScript in ApexChart. I guess ApexChart is made up with JavaScript and its type doesn't look like appropriate in React18

blingblin-g avatar Apr 13 '22 07:04 blingblin-g

I also get this error!

raphaeljoer avatar Jun 28 '22 20:06 raphaeljoer

I've just solved this problem with // @ts-ignore on the component <ApexChart /> like this below.

        // @ts-ignore
        <ApexChart
          type="line"

I think it has an issue with React v18 and TypeScript in ApexChart. I guess ApexChart is made up with JavaScript and its type doesn't look like appropriate in React18

This works for me

GusMartins499 avatar Jul 27 '22 19:07 GusMartins499