Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue <Icons /> cannot be used as a JSX component. #39

Open
ducqhl opened this issue May 21, 2022 · 6 comments
Open

Issue <Icons /> cannot be used as a JSX component. #39

ducqhl opened this issue May 21, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@ducqhl
Copy link

ducqhl commented May 21, 2022

Issue details:

TS2786: 'Gear' cannot be used as a JSX component.
  Its element type 'ReactElement<any, any> | Component<Props, any, any> | null' is not a valid JSX element.
    Type 'Component<Props, any, any>' is not assignable to type 'Element | ElementClass | null'.
      Type 'Component<Props, any, any>' is not assignable to type 'ElementClass'.
        The types returned by 'render()' are incompatible between these types.
          Type 'React.ReactNode' is not assignable to type 'import("/Users/ducqhle/Documents/_workspace/my-practices/sbox-internal-app/node_modules/@types/react-transition-group/node_modules/@types/react/index").ReactNode'.
            Type '{}' is not assignable to type 'ReactNode'.
              Type '{}' is missing the following properties from type 'ReactPortal': key, children, type, props
    25 |           <Col xs={1}>
    26 |             <Stack gap={3}>
  > 27 |               <Gear size={18} />
       |                ^^^^
    28 |               <PeopleFill size={18} />
    29 |               <CheckCircle size={18} />
    30 |             </Stack>

Versions:
"react-bootstrap-icons": "^1.8.2",
"react-bootstrap": "^2.4.0",
"react": "18.0.0",

Can anyone know how can we fix this issue when integrate react-bootstrap-icons with typescript React project?

@nickives
Copy link

I'm having this issue since upgrading to React 18. I think the problem is that {} used to be a valid ReactNode, but they fixed it in React 18. So, I assume the type of Icon in react-bootstrap-icons needs to be updated.

@ismamz
Copy link
Owner

ismamz commented May 24, 2022

hi @ducqhl, thanks for reporting this issue. I'll update soon to fix it.

@ismamz
Copy link
Owner

ismamz commented Jun 15, 2022

@ducqhl this should be fixed with React 18.2.0 and @types/react 18.0.12

@dzpt
Copy link

dzpt commented Sep 1, 2022

i got this error even in react 17
@ismamz

├── [email protected]
├── [email protected]
├── [email protected]
├── @types/[email protected]

@dantabel
Copy link

dantabel commented Sep 7, 2022

+1 I also get this issue in React 17

@ismamz ismamz added the bug Something isn't working label Sep 27, 2022
@ismamz
Copy link
Owner

ismamz commented Sep 27, 2022

@dzpt @dantabel could you provide me a CodeSandbox example to reproduce this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants