Comments (21)
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.
👋 Very simple solution: this return this.props.children
replace with return <>{this.props.children}</>
from react-error-boundary.
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.
Upgrading to "@types/react": "18.0.9"
fixed it.
from react-error-boundary.
I added
"resolutions": {
"@types/react": "^17.0.0"
}
to my package.json to pin to @types/react v17 for now
from react-error-boundary.
Need to upgrade the version of @types/react
from react-error-boundary.
Same issue
from react-error-boundary.
Having the same issue as well
from react-error-boundary.
Same here
from react-error-boundary.
upgraded my App's @types/react
which solved issue.
from react-error-boundary.
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.
probably related to changes in @types/react v18
from react-error-boundary.
Also facing this same issue
from react-error-boundary.
I also have the same issue.
from react-error-boundary.
Same here
from react-error-boundary.
same here
from react-error-boundary.
Same issue
from react-error-boundary.
Same here
from react-error-boundary.
Same here
from react-error-boundary.
Same here
from react-error-boundary.
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)
- 'ErrorBoundaryContext not found' appears when using useErrorBoundary HOT 12
- Error when rendering inside a server component in Next.js HOT 7
- 'ErrorBoundary' cannot be used as a JSX component. HOT 10
- Reset error state on router changed HOT 2
- [New feature request] add `ErrorBoundaryGroup` like @suspensive/react HOT 2
- [Proposal] Propagate original error when no fallback was provided HOT 5
- 4.0.11 cannot find module 'react-error-boundary' or its corresponding type declarations. HOT 1
- [Proposal] Detect an infinite loop of resetting the error HOT 4
- type ErrorBoundaryPropsWithFallback allows fallback to be null HOT 4
- How to customize error HOT 3
- NPM Install Fails with 404 for 'react-rerror-bounday' Package HOT 4
- Preventing React unmounting UI on error? HOT 3
- useErrorBoundary as global HOT 2
- doesn't catch errors thrown by new Error('error text') but catches errors thrown by throw 'error text' HOT 1
- 'ErrorBoundary' cannot be used as a JSX component. HOT 3
- Getting children of ErrorBoundary in render functions HOT 1
- Bug with catching errors when using React Router HOT 1
- `fallback` function is not allowing to render `ReactPortal` via `createPortal()` function HOT 3
- Trying to access an eslint configuration that is not a dependency of react-error-boundary HOT 4
- "use client" not appearing in the ESM entry HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-error-boundary.