Skip to content
Discussion options

You must be logged in to vote

Functions passed to scheduleOnRN must be defined in the RN Runtime scope, i.e. in the component body or the global scope.
The code below won't work because myFunction is defined in the runOnUI callback, which is only executed in the UI Runtime:

import { runOnUI, scheduleOnRN } from 'react-native-worklets';

runOnUI(() => {
  // myFunction is defined on the UI thread 🚨
  const myFunction = () => {
    // ...
  };
  scheduleOnRN(myFunction)(); // 💥
})();

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MatiPl01
Comment options

Answer selected by MatiPl01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants