Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React 18.2 defaultProps error #730

Open
liuhe2020 opened this issue May 13, 2023 · 8 comments · Fixed by #733
Open

React 18.2 defaultProps error #730

liuhe2020 opened this issue May 13, 2023 · 8 comments · Fixed by #733

Comments

@liuhe2020
Copy link

liuhe2020 commented May 13, 2023

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
Copy link

armandoborge commented Jun 26, 2023

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
Copy link

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

@liuhe2020
Copy link
Author

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
Copy link

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
Copy link
Author

@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
Copy link

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

@xiaolin
Copy link
Owner

xiaolin commented Jul 31, 2023

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants