This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Maxim Raykhrud
Posted Apr 30 - Read on Facebook


I seem to be running into a particularly annoying error that occurs when I am trying to copy a layer in one particular file.

All I am getting is "TypeError: Layer is not a constructor (evaluating 'new Image()')" and traceback is not pointing at any bits of my own code, just some stuff in Framer and CoffeeScript.

Could this be an import error? I am not getting this when calling .copy() on layers from other files and the the same version of Framer.

Here's the prototype I have:



Koen Bok

This is a pretty great example of why keeping your imports in a sketch object is a great idea :-)

You have a layer named Image that you set globally on the window below. Now, insider Framer it tries to set an Image object on copy. But that just became your image layer so you get really unexpected results.

If you really really want to have your layers as globals, use Utils.globalLayers(sketch). It will warn if you override window values.

#importing #globals

Maxim Raykhrud

Thank you! A great example for not using global scope indeed.

Koen Bok

If you don't want to type you can always use a single letter variable like $.

Read the entire post on Facebook