react-image-gallery icon indicating copy to clipboard operation
react-image-gallery copied to clipboard

React 18.2 defaultProps error

Open liuhe2020 opened this issue 1 year ago • 8 comments

I updated to React 18.2, in a Next 13 project and now it is giving me this warning. The component works fine still though. I had a look around and it looks like defaultprops are going to be deprecated in React 18.3? Is this the reason why I am getting this warning? As I can see that in the source code the Item class component has defaultProps set.

Warning: Item: Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead. at div at div at div at div at div at l (webpack-internal:///(app-client)/./node_modules/.pnpm/[email protected][email protected]/node_modules/react-image-gallery/build/image-gallery.js:1:23859)

liuhe2020 avatar May 13 '23 23:05 liuhe2020

I am still seeing this warning using the latest version v1.2.12

"dependencies": {
  "eslint": "^8.43.0",
  "eslint-config-next": "^13.4.6",
  "framer-motion": "^10.12.16",
  "next": "^13.4.7",
  "next-intl": "^2.15.1",
  "react": "^18.2.0",
  "react-dom": "^18.2.0",
  "react-image-gallery": "^1.2.12",
  "sharp": "^0.32.1"
},

armandoborge avatar Jun 26 '23 13:06 armandoborge

That's right, the warning of defaultProps is still there @xiaolin

saloavalos avatar Jul 02 '23 15:07 saloavalos

That's correct, because the latest version is out of sync with the repo. The repo has the up to date code without using defaultProps, but if you install via package manager, you still get the old version. For now I manually changed the code in node modules. Replace the code in node modules with code from src/item.js in this repo.

liuhe2020 avatar Jul 02 '23 16:07 liuhe2020

That's correct, because the latest version is out of sync with the repo. The repo has the up to date code without using defaultProps, but if you install via package manager, you still get the old version. For now I manually changed the code in node modules. Replace the code in node modules with code from src/item.js in this repo.

I tried it, but I checked that the code is actually the same as the one I already have, maybe ImageGallery is missing @liuhe2020

saloavalos avatar Jul 18 '23 11:07 saloavalos

@saloavalos Yes, you are right, ImageGallery hasn't been updated yet. Maybe you can change the code the same way as in item.js to remove defaultProps as a fix, until the repo gets updated.

liuhe2020 avatar Jul 19 '23 18:07 liuhe2020

@xiaolin can you check this please. The warning of defaultProps is still there

misowebdev avatar Jul 31 '23 00:07 misowebdev

Can someone list steps to reproduce? The only component using defaultProps is the main class based component, so I'm confused where this warning is coming from.

xiaolin avatar Jul 31 '23 04:07 xiaolin

Can someone list steps to reproduce? The only component using defaultProps is the main class based component, so I'm confused where this warning is coming from.

actually, I just updated to 1.3.0 and no more warnings.

misowebdev avatar Aug 02 '23 18:08 misowebdev