xiaolin / react-image-gallery

React carousel image gallery component with thumbnail support 🖼
http://linxtion.com/demo/react-image-gallery
MIT License
3.74k stars 708 forks source link

React 18.2 defaultProps error #730

Open liuhe2020 opened 1 year ago

liuhe2020 commented 1 year ago

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/react-image-gallery@1.2.11_react@18.2.0/node_modules/react-image-gallery/build/image-gallery.js:1:23859)

armandoborge commented 1 year ago

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"
  },
saloavalos commented 1 year ago

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

liuhe2020 commented 1 year ago

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.

saloavalos commented 12 months ago

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

liuhe2020 commented 12 months ago

@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.

misowebdev commented 11 months ago

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

xiaolin commented 11 months ago

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.

misowebdev commented 11 months ago

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.