Giter VIP home page Giter VIP logo

Comments (21)

zlargon avatar zlargon commented on May 8, 2024 13

This issue is caused by the breaking change from @types/react v18.

Use command npm ls @types/react to see if you have any @types/[email protected] in your dependencies.

You can upgrade react v18, or update @types/[email protected] version in your lock file.

Checkout the solution from these comments:

from react-error-boundary.

floatrx avatar floatrx commented on May 8, 2024 12

👋 Very simple solution: this return this.props.children replace with return <>{this.props.children}</>

from react-error-boundary.

edouardmisset avatar edouardmisset commented on May 8, 2024 10

I also have the same issue.

'ErrorBoundary' cannot be used as a JSX component.
  Its instance type 'ErrorBoundary' 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/ext_em/code/innova-web-ui-proto/node_modules/@types/react-redux/node_modules/@types/react/index").ReactNode'.
        Type '{}' is not assignable to type 'ReactNode'.

package.json

  "dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-error-boundary": "^3.1.4",
    ...
}

from react-error-boundary.

nick-kang avatar nick-kang commented on May 8, 2024 8

Upgrading to "@types/react": "18.0.9" fixed it.

from react-error-boundary.

cmdcolin avatar cmdcolin commented on May 8, 2024 4

I added

  "resolutions": {
    "@types/react": "^17.0.0"
  }

to my package.json to pin to @types/react v17 for now

from react-error-boundary.

Hendry5479 avatar Hendry5479 commented on May 8, 2024 4

Need to upgrade the version of @types/react

from react-error-boundary.

andreribeiro27 avatar andreribeiro27 commented on May 8, 2024 2

Same issue

from react-error-boundary.

AndyJPG avatar AndyJPG commented on May 8, 2024 2

Having the same issue as well

from react-error-boundary.

fabioebt avatar fabioebt commented on May 8, 2024 1

Same here

from react-error-boundary.

lucksp avatar lucksp commented on May 8, 2024 1

upgraded my App's @types/react which solved issue.

from react-error-boundary.

kaspnilsson avatar kaspnilsson commented on May 8, 2024

Also getting this in my project, it appears to have something to do with the version of react I have in my project being different than what's expected.

Key code lines:

import { ReactNode } from 'react'
import { ErrorBoundary as ReactErrorBoundary } from 'react-error-boundary'

interface Props {
  children: ReactNode
}

const ErrorBoundary = ({ children }: Props) => {
// my custom wrapping code
  return (
    <ReactErrorBoundary FallbackComponent={ErrorFallback} onError={onError}>
      {children}
    </ReactErrorBoundary>
  )
}

Error:
'ReactErrorBoundary' cannot be used as a JSX component.
Its instance type 'ErrorBoundary' 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/hoist-non-react-statics/node_modules/@types/react/index").ReactNode'.
Type '{}' is not assignable to type 'ReactNode'.

The particular node module it conflicts with changes each time I do a fresh yarn install, so it seems to be an issue with this lib as opposed to other deps.

from react-error-boundary.

cmdcolin avatar cmdcolin commented on May 8, 2024

probably related to changes in @types/react v18

from react-error-boundary.

mantey-github avatar mantey-github commented on May 8, 2024

Also facing this same issue

from react-error-boundary.

tomtang1122 avatar tomtang1122 commented on May 8, 2024

I also have the same issue.

from react-error-boundary.

nardocesar avatar nardocesar commented on May 8, 2024

Same here

from react-error-boundary.

sam-frampton avatar sam-frampton commented on May 8, 2024

same here

from react-error-boundary.

bnheise avatar bnheise commented on May 8, 2024

Same issue

from react-error-boundary.

blockmood avatar blockmood commented on May 8, 2024

Same here

from react-error-boundary.

Gyumong avatar Gyumong commented on May 8, 2024

Same here

from react-error-boundary.

mayassalman avatar mayassalman commented on May 8, 2024

Same here

from react-error-boundary.

bvaughn avatar bvaughn commented on May 8, 2024

Assuming this is the solution, this issue should no longer be relevant with v4 since ErrorBoundary will wrap children within a <Context.Provider>. Let's re-open with a repro case if the issue still happens in v4.

from react-error-boundary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.