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 supportsMicrotasks to the host config #20809

Merged
merged 2 commits into from
Feb 12, 2021

Commits on Feb 12, 2021

  1. Add supportsMicrotasks to the host config

    Only certain renderers support scheduling a microtask, so we need a
    renderer specific flag that we can toggle. That way it's off for some
    renderers and on for others.
    
    I copied the approach we use for the other optional parts of the host
    config, like persistent mode and test selectors.
    
    Why isn't the feature flag sufficient?
    
    The feature flag modules, confusingly, are not renderer-specific, at
    least when running the our tests against the source files. They are
    meant to correspond to a release channel, not a renderer, but we got
    confused at some point and haven't cleaned it up.
    
    For example, when we run `yarn test`, Jest loads the flags from the
    default `ReactFeatureFlags.js` module, even when we import the React
    Native renderer — but in the actual builds, we load a different feature
    flag module, `ReactFeatureFlags.native-oss.js.` There's no way in our
    current Jest load a different host config for each renderer, because
    they all just import the same module. We should solve this by creating
    separate Jest project for each renderer, so that the flags loaded when
    running against source are the same ones that we use in the
    compiled bundles.
    
    The feature flag (`enableDiscreteMicrotasks`) still exists — it's used
    to set the React DOM host config's `supportsMicrotasks` flag to `true`.
    (Same for React Noop) The important part is that turning on the feature
    flag does *not* affect the other renderers, like React Native.
    
    The host config will likely outlive the feature flag, too, since the
    feature flag only exists so we can gradually roll it out and measure the
    impact in production; once we do, we'll remove it. Whereas the host
    config flag may continue to be used to disable the discrete microtask
    behavior for RN, because RN will likely use a native (non-JavaScript)
    API to schedule its tasks.
    acdlite committed Feb 12, 2021
    Configuration menu
    Copy the full SHA
    5a653de View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0c2c7f2 View commit details
    Browse the repository at this point in the history