question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`croppie.destroy()` causes errors

See original GitHub issue

Error 1

// This error happens because `opts.update()` is called after `destroy()`

Uncaught (in promise) TypeError: Cannot read property 'preview' of undefined
    at Croppie._get (webpack-internal:///223:1318:37)
    at Croppie._result (webpack-internal:///223:1353:25)
    at Croppie.result (webpack-internal:///223:1569:28)

Error 2

// This error happens because `_updateOverlay()` is triggered by `_debouncedOverlay()`
// after a `destroy()`, and `self.elements` is null

Uncaught TypeError: Cannot read property 'boundary' of undefined
    at Croppie._updateOverlay (croppie.js?f101:939)
    at later (croppie.js?f101:102)
function _updateOverlay() {
        var self = this,
            boundRect = self.elements.boundary.getBoundingClientRect(),
            imgData = self.elements.preview.getBoundingClientRect();
...
}

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ckmahoneycommented, May 30, 2019

I was encountering this because I had moved one of the Croppie components (the zoom slider) from the Croppie container into our container.

Calling destroy() with some Croppie elements intentionally placed elsewhere in the DOM threw an error. It looked like Croppie was trying to search for known children and couldn’t find them in the original parent container.

When I put the slider back into the original Croppie container, then proceed to can call destroy(), the instance is destroyed without error.

1reaction
thedustinsmithcommented, Nov 17, 2017

Good catch. I guess the simplest fix would be adding a

if (!self.elements) return;

at the top of the _updateOverlay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

destroy or reset image croppie - javascript - Stack Overflow
The problem I've had with destroy is that once you destroy the instance, then you go to reinitialize croppie after that (say after...
Read more >
Unexpected token < in JSON at position 0 - Dave Ceddia
The root cause is that the server returned HTML or some other non-JSON string. Why would it do that? “Unexpected token o in...
Read more >
STATE OF MINNESOTA - MN.gov
Emergencies Caused by a Storm, Act of God, Power Loss, or Similar Event. ... An “error” in Frontier's software caused the wrong closing...
Read more >
December 20, 2018 FERC Project No. 2336-094 Lloyd Shoals ...
of a fish kill in a cove of Lake Jackson near Elizabeth Circle in Butts ... their cause, severity, and measures taken to...
Read more >
Roy Lake State Park - South Dakota - Game, Fish, and Parks
Other species include black bullhead, black crappie, bluegill, ... k) The Department makes no representations as to the validity of the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found