Search code examples
reactjsreact-bootstrap

Is React-bootstrap compatible with React 18?


I would like to migrate my application to React 18 but after doing so, I got errors like this

This JSX tag's  children  prop expects a single child of type  ReactNode , but multiple children were provided.

or

Type  () => Element  is not assignable to type  () => ReactNode 
Type  Element  is not assignable to type  ReactNode 
Property  children  is missing in type  Element  but required in type  ReactPortal

I looked at React-bootstrap code on github (version 2.9.0 at time of writing) and it still uses React 16.

Should it work?

I made sure that the same version of react and @types/react is used by all dependencies, using npm ls xxx


Solution

  • I looked at React-bootstrap code on github (version 2.9.0 at time of writing) and it still uses React 16.

    Should it work?

    Yes, it should.

    The npm page of the project doesn't even state react as a direct dependency, and if you look at the peerDependencies section of the package.json file:

    "peerDependencies": {
      "@types/react": ">=16.14.8",
      "react": ">=16.14.0",
      "react-dom": ">=16.14.0"
    },
    

    it states that it requires React 16 or higher as a peer dependency.