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

Add HostFunction handling to _scheduleOnJS #6571

Merged

Conversation

bartlomiejbloniarz
Copy link
Contributor

@bartlomiejbloniarz bartlomiejbloniarz commented Oct 4, 2024

Summary

Currently, when a Host Function is called through runOnJS the app crashes, since we are only handling Remote Function in the _scheduleOnJS method. For example the following code leads to a crash:

useEffect(() => {
    const id = setInterval(() => {
      console.log('interval');
    }, 1000);
    const intervalAlias = clearInterval;
    runOnUI(() => {
      runOnJS(intervalAlias)(id);
    })();
  }, []);

This example works fine on the old architecture, because Timer functions are polyfilled there. On the New Architecture they are Host Functions, so we need to handle them separately.

Test plan

Check

useEffect(() => {
    const id = setInterval(() => {
      console.log('interval');
    }, 1000);
    const intervalAlias = clearInterval;
    runOnUI(() => {
      runOnJS(intervalAlias)(id);
    })();
  }, []);

Copy link
Member

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bartlomiejbloniarz bartlomiejbloniarz added this pull request to the merge queue Oct 4, 2024
Merged via the queue into main with commit 49c797e Oct 4, 2024
19 checks passed
@bartlomiejbloniarz bartlomiejbloniarz deleted the @bartlomiejbloniarz/add-host-function-to-scheduleOnJS branch October 4, 2024 14:43
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

Successfully merging this pull request may close these issues.

2 participants