rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.91k stars 862 forks source link

'PersistGate' cannot be used as a JSX Component #1399

Open harlankoehn opened 1 year ago

harlankoehn commented 1 year ago

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

ElForastero commented 1 year ago

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

bihongbin3027 commented 1 year ago

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

panoramix360 commented 1 year ago

Did you find a way to fix it?

I'm getting the same error today.

ryanpcmcquen commented 9 months ago

Still an issue.