Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'SVGElement' of undefined #162

Closed
tlrobinson opened this issue May 25, 2016 · 5 comments
Closed

Comments

@tlrobinson
Copy link

In v2.1.1 I'm getting this error when trying to use Draggable:

react-draggable.js:267 Uncaught TypeError: Cannot read property 'SVGElement' of undefined

It looks like the problem has to do with global being undefined due to (function() { return this; })() returning null rather than the global object in strict mode. I'm not really sure why it's being executed in strict mode though.

@STRML
Copy link
Collaborator

STRML commented May 25, 2016

That's odd. Strict mode is intended and implied in Babel modules, but Webpack should be handling global injection properly.

I don't see this issue on any of the demos. Perhaps it has something to do with your environment?

@artemstorozhuk
Copy link

Exactly same issue for me. I've got no idea how to fix it.

@STRML
Copy link
Collaborator

STRML commented Jun 5, 2016

You could help by giving me reproduction steps.

@artemstorozhuk
Copy link

artemstorozhuk commented Jun 5, 2016

Thanks for your quick response.

In console:
npm i --save react-draggable

In code:

import React from 'react'
import {render} from 'react-dom'
import Draggable from 'react-draggable';

render(
    <Draggable>
        <div>content</div>
    </Draggable>,
    document.getElementById('root')
);

Btw component is dragging properly.

@amoilanen
Copy link
Contributor

Might be that I found a workaround.

Observed the same error when the code of react-draggable was run through the Babel transform by Webpack while being located under 'node_modules'. After turning off the Babel transform the issue disappeared, now no errors in the console.

Looks like some Webpack + Babel issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants