react-image-gallery
react-image-gallery copied to clipboard
React 18.2 defaultProps error
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)
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"
},
That's right, the warning of defaultProps
is still there @xiaolin
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.
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 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.
@xiaolin can you check this please. The warning of defaultProps is still there
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.
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.