React-sketchapp: ReferenceError: Can't find variable: setTimeout

Created on 15 May 2017  路  2Comments  路  Source: airbnb/react-sketchapp

i'm running the basic-setup example, getting an error when trying to setTimeout.
why is that?

Most helpful comment

Added in [email protected] 馃槃

All 2 comments

Hey @talarari!

Sketch's JS environment doesn't provide setTimeout. We should polyfill it in skpm (like we did with console & fetch), but until then, this snippet in your main function should work.

export default (context) => {
  // setInterval - note that time is in seconds, not milliseconds
  coscript.shouldKeepAround = true;
  coscript.scheduleWithInterval_jsFunction(1.0, (cinterval) => {
    log('after 1 second!');
    coscript.shouldKeepAround = false;
  });
}

Added in [email protected] 馃槃

Was this page helpful?
0 / 5 - 0 ratings