image-map-resizer
image-map-resizer copied to clipboard
React
Has anyone been able to get this working with react? I am just migrate my project to react now and having some trouble getting this to work.
I don’t think this will work in React in it’s current form, but now you have me thinking what a React version would look like. I will give it some thought over the weekend
got it to work, just render the html area map like you normally would, import imageMapResize from 'image-map-resizer' and call imageMapResize inside componentDidMount() makes sense aha,
I have done the as @antonydellavecchia but I am getting an error ReferenceError: window is not defined at /something/node_modules/image-map-resizer/js/imageMapResizer.min.js:7:1833
One additional thing I had to do (in addition to what @antonydellavecchia said is add the following eslint rule:
/* eslint no-undef: "off"*/
Hi @jdejesus001 , Where should I add that rule? I'm also facing the same error as miritun when refresh page. I'm using nextjs, typescript.
Would be easier to set the esLint environment to browser
{
"env": {
"browser": true
}
}
I added the rule on line 147 of the ImageMapResizer file:
/* eslint no-undef: "off"*/
if (typeof define === 'function' && define.amd) {
define([], factory)
} else if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = factory() //Node for browserfy
} else {
window.imageMapResize = factory()
}
Nice job btw David. I have this working perfectly in React.
for those doing it in nextjs, this worked for me:
useEffect(() => {
import("image-map-resizer").then((module) => module.default());
}, []);