guides icon indicating copy to clipboard operation
guides copied to clipboard

Uncaught TypeError: Cannot assign to read only property

Open drumnation opened this issue 4 years ago • 1 comments

Environments

  • Framework name: react-guides 12.1.0

I first got this when saving a non cloned element to redux. We fixed it by cloning the guides array [...guides] before setting it to redux. Then I got this error with it happening on dragEnd and scratched my head. The only place setting a read only value could be inside the library in this case.

guides.esm.js:203 Uncaught TypeError: Cannot assign to read only property '2' of object '[object Array]'
    at Object.Guides._this.onDragEnd [as listener] (guides.esm.js:203)
    at event-emitter.esm.js:211
    at Array.forEach (<anonymous>)
    at Gesto.__proto.emit (event-emitter.esm.js:210)
    at HTMLBodyElement.Gesto._this.onDragEnd (gesto.esm.js:444)

I went through and changed all the references to this.state.guides to [...this.state.guides], recompiled, and no more read only error.

It's getting hung up on this line.

guides[index] = pos;

Where guides is read only and can't add pos, throwing the type error.

drumnation avatar Feb 23 '21 22:02 drumnation

@drumnation react-guides 0.13.0 is released. Check it again

daybrush avatar Feb 27 '21 16:02 daybrush