defaultProps being deprecated
Closed this issue · 10 comments
Describe the bug
React defaultProps is scheduled to be deprecated in the next major release, 18.3: see here
To Reproduce
Steps to reproduce the behavior:
Mounting ImageMapper with React 18.2 generates this warning.
Error Stack
Warning: ImageMapper: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead. at ImageMapper (webpack-internal:///(app-client)/./node_modules/.pnpm/react-img-mapper@1.5.1_react-dom@18.2.0_react@18.2.0/node_modules/react-img-mapper/dist/ImageMapper.js:60:30)
Expected behavior
Change the default props syntax to the ES6 standard to remove this warning and prevent future bugs. See an example in this thread.
Screenshots
N/A
I get this warning and nothing renders. Is this the same for you @ethan-carlson or do you get the component rendering? Just using the example code (replaced the json url with the actual json array)
It is just a warning, the functionality will not affect due to this issue
It is just a warning, the functionality will not affect due to this issue
In that case, I've added a new issue
Any idea hot to fix or any library to get it on nextjs 13 ?
Hello @marcuspx I am currently, working on it. please wait for sometime.
Hi, I am using Nextjs 14, in my localhost everything works fine , but after switching browser tabs, the highlighted portions dissapears (even after setting stayMultiHighlighted
) and the areas are no longer highlighted when I hover over them. If I do a full page refresh, it works fine again, are you also faching this @marcuspx ?
Hello @ethan-carlson, this issue is resolved in the newer pre-release
Please check https://www.npmjs.com/package/react-img-mapper/v/2.0.0-alpha.1
Related to the Next.js highlighting issue, please create a separate one
Thanks :)
@ronalddas ,for some reason in Local is showing the error but on production is not, no idea why but I'll wait for the stable version on nextjs from @NishargShah
Hello @marcuspx, in the alpha version, it is resolved. Please wait till the stable release if you are using this package in any real projects
This is not a solution but just a work around for this issue. This just hides the warning.
const error = console.error;
console.error = (...args) => { if (/defaultProps/.test(args[0])) return; error(...args); };