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

'SideNavigation' cannot be used as a JSX component. #606

Closed
chestonchow opened this issue Apr 10, 2022 · 5 comments
Closed

'SideNavigation' cannot be used as a JSX component. #606

chestonchow opened this issue Apr 10, 2022 · 5 comments
Assignees

Comments

@chestonchow
Copy link

Hi there,

I have this following error just by importing it and it doesn't seem any other code on top of this is causing this error. Can I get some help for this?

Thanks,
Cheston

'SideNavigation' cannot be used as a JSX component.
  Its instance type 'Component<Pick<SideNavigationProps, "header" | "items" | "defaultExpandedAll"> & ({} | { wrappedComponentRef?: Ref<any> | undefined; }), any, any>' 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("/home/user/website/node_modules/@types/react-router/node_modules/@types/react/index").ReactNode'.
        Type '{}' is not assignable to type 'ReactNode'.  TS2786

    75 |     }
    76 | 
  > 77 |     const navigation = <SideNavigation header={{ href: '/', text: 'asdfasdf'}}/>;
       |                         ^
    78 |     // const navigation = <SideNavigation header={{ href: '/', text: 'asdfasdf'}} items={navigationItems}/>;
    79 | 
    80 |     return (

Here are my package.json dependencies

  "dependencies": {
    "@aws-amplify/ui-react": "^2.15.1",
    "@mui/styles": "^5.4.1",
    "aws-amplify": "^4.3.19",
    "aws-northstar": "^1.3.12",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-feather": "^2.0.9",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.4",
    "which": "2.0.2"
  },
  "devDependencies": {
    "@types/react": "^17.0.2",
    "@types/react-dom": "^17.0.2",
    "@types/react-router-dom": "^5.3.3",
    "typescript": "^4.6.2"
  },
@jessieweiyi
Copy link
Contributor

Thanks @chestonchow for reporting this issue. We will have a look today.

Does this issue happen after you update any dependencies?

@jessieweiyi
Copy link
Contributor

Hi @chestonchow,

This issue is related to the new major version 18 of @types/react released 3 days ago. Some of the dependencies NorthStar is using are still relying on v17.

See:
@types/react@18 break @types/styled-components
@types/react@18 breaks "everything".

While we are continuing working on upgrading NorthStar to be compatible with new React 18,
please check whether you are using React version 17 and use one of the following temporary fixes to suppress the build error:

  1. use @ts-ignore for the block; or
  2. add resolution to your package.json if you are using yarn:
  "resolutions": {
    "@types/react": "^17",
    "@types/react-dom": "^17"
  },

We will update this thread if we find better solution for this issue.

@jessieweiyi jessieweiyi pinned this issue Apr 11, 2022
@jessieweiyi jessieweiyi unpinned this issue Apr 11, 2022
@jessieweiyi
Copy link
Contributor

@chestonchow
Copy link
Author

Hi Jessie,

Thanks for following up! I didn't update to use React 18 yet as per my post earlier when the error came up, which is what confuses me. I might just put in @ts-ignore for now.

Thanks,
Cheston

themikejr added a commit to Clear-Bible/TreedownAligner that referenced this issue Apr 11, 2022
What a pain. Something has gone wrong with the typings for React 18
and the way that libraries specify the types being used.
This commit avoids/suppresses the issue for now.

See:
- facebook/react#24304
- aws/aws-northstar#606
@jessieweiyi jessieweiyi self-assigned this Apr 11, 2022
@gaearon
Copy link

gaearon commented Apr 12, 2022

Would it make sense to change the dependencies on types to be optional peer deps? facebook/react#24304 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants