redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

'PersistGate' cannot be used as a JSX Component

Open harlankoehn opened this issue 3 years ago • 4 comments

We are getting TypeScript error TS2786:

'PersistGate' cannot be used as a JSX component. Its instance returned by 'render()' are incompatible between these types. Type 'React.ReactNode' is not assignable to type 'import("C:/OurAppFolder/node_modules/@types/react-redux/@types/react/index").ReactNode'.

The relevant pieces in our package.json are:

{
  "dependencies": {
    "@types/react": "17.0.9",
    "@types/react-dom": "17.0.6",
    "@types/react-redux": "^7.1.12",
    "devextreme": "^22.1.3",
    "devextreme-react": "^22.1.3",	
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-idle-timer": "^4.6.4",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.9",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^2.3.0",
  }
}

When we add a resolutions entry (as seen below) to our package.json file, this error goes away:

"resolutions": {
  "@types/react": "17.0.2",
  "@types/react-dom": "17.0.2"
}

However, this is a bandaid that causes us some problems with other packages that expect newer versions of the React Types.

This problem has previously been mentioned on StackOverflow but I couldn't find anything when I searched through past issues: https://stackoverflow.com/questions/71826046/react-native-persistgate-cannot-be-used-as-a-jsx-component-its-instance-type

harlankoehn avatar Jul 25 '22 20:07 harlankoehn

Same error. I'm not sure in what way should we fix this.

ElForastero avatar Aug 07 '22 11:08 ElForastero

Same error. I'm not sure in what way should we fix this.

bihongbin3027 avatar Sep 16 '22 01:09 bihongbin3027

Did you find a way to fix it?

I'm getting the same error today.

panoramix360 avatar Mar 29 '23 17:03 panoramix360

Still an issue.

ryanpcmcquen avatar Oct 03 '23 23:10 ryanpcmcquen