mosch / react-avatar-editor

Small avatar & profile picture component. Resize and crop uploaded images using a intuitive user interface.
https://react-avatar-editor.netlify.app/
MIT License
2.35k stars 369 forks source link

With the new version 13.0.1 in production I'm getting "Cannot call a class as a function" #409

Closed stinkokenzo closed 8 months ago

stinkokenzo commented 9 months ago

I've updated to the 13.0.1 and works well in development but in production I'm getting: Cannot call a class as a function .

The chunks where the error happen is:

function r(e){var t;if(this instanceof r)return s(p(t=C.call(this,e)),"state",{drag:!1,my:null,mx:null,image:S}),s(p(t),"handleImageReady",function(e){var a=t.getInitialSize(e.width,e.height);a.resource=e,a.x=.5,a.y=.5,a.backgroundColor=t.props.backgroundColor,t.setState({drag:!1,image:a},t.props.onImageReady),t.props.onLoadSuccess(a)}),s(p(t),"clearImage",function(){t.canvas.getContext("2d").clearRect(0,0,t.canvas.width,t.canvas.height),t.setState({image:S})}),s(p(t),"handleMouseDown",function(e){(e=e||window.event).preventDefault(),t.setState({drag:!0,mx:null,my:null})}),s(p(t),"handleMouseUp",function(){t.state.drag&&(t.setState({drag:!1}),t.props.onMouseUp())}),s(p(t),"handleMouseMove",function(e){var a,l,c,b,w,x,k,S,M,C;e=e||window.event,!1!==t.state.drag&&(e.preventDefault(),a={mx:l=e.targetTouches?e.targetTouches[0].pageX:e.clientX,my:c=e.targetTouches?e.targetTouches[0].pageY:e.clientY},C=(C=t.props.rotate%360)<0?360+C:C,t.state.mx&&t.state.my&&(l=t.state.mx-l,c=t.state.my-c,b=t.state.image.widtht.props.scale,w=t.state.image.heightt.props.scale,x=(S=t.getCroppingRect()).x,S=S.y,x=b,S=w,k=Math.cos((M=function(e){return e(Math.PI/180)})(C)),M=S+-l(S=Math.sin(M(C)))+ck,C={x:(x+lk+cS)/b+1/t.props.scalet.getXScale()/2,y:M/w+1/t.props.scale*t.getYScale()/2},t.props.onPositionChange(C),a.image=d(d({},t.state.image),C)),t.setState(a),t.props.onMouseMove(e))}),s(p(t),"setCanvas",function(e){t.canvas=e}),t.canvas=null,t;throw TypeError("Cannot call a class as a function")

Seems that in the function r(e) when checking if(this instanceof r).

Downgrade to the 13.0.0 solve the error.

eduardo6722 commented 9 months ago

same issue here

dan-lee commented 9 months ago

Hm, something seems to have gone wrong there. v13.0.2 should work again.