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

Dedup conditional in ReactScheduler #12680

Merged
merged 1 commit into from
Apr 24, 2018

Conversation

flarnie
Copy link
Contributor

@flarnie flarnie commented Apr 24, 2018

what is the change?:
We had a condition to set either 'performance.now' or 'Date.now' as the
'now' function.

Then later we had another conditional checking again if
'performance.now' was supported, and using it if so, otherwise falling
back to 'Date.now'.

More efficient to just use the 'now' shortcut defined above.

why make this change?:
Fewer lines, clearer code.

test plan:
Now that we have tests we can run them :)

**what is the change?:**
We had a condition to set either 'performance.now' or 'Date.now' as the
'now' function.

Then later we had another conditional checking again if
'performance.now' was supported, and using it if so, otherwise falling
back to 'Date.now'.

More efficient to just use the 'now' shortcut defined above.

**why make this change?:**
Fewer lines, clearer code.

**test plan:**
Now that we have tests we can run them :)
Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

Looks ok to me

@pull-bot
Copy link

ReactDOM: size: -0.1%, gzip: -0.1%

Details of bundled changes.

Comparing: 09a14ea...e976c67

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -0.1% -0.0% 611.67 KB 611.19 KB 141.35 KB 141.28 KB UMD_DEV
react-dom.production.min.js -0.1% -0.1% 100.41 KB 100.3 KB 31.88 KB 31.85 KB UMD_PROD
react-dom.development.js -0.1% -0.1% 596.05 KB 595.56 KB 137.21 KB 137.14 KB NODE_DEV
react-dom.production.min.js -0.1% -0.0% 98.85 KB 98.74 KB 31.07 KB 31.05 KB NODE_PROD
ReactDOM-dev.js -0.1% -0.0% 620.48 KB 619.99 KB 139.92 KB 139.85 KB FB_WWW_DEV
ReactDOM-prod.js -0.1% -0.1% 284.29 KB 283.99 KB 51.97 KB 51.93 KB FB_WWW_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -0.1% -0.1% 414.59 KB 414.1 KB 90.22 KB 90.15 KB UMD_DEV
react-art.production.min.js -0.1% 🔺+0.1% 90.73 KB 90.62 KB 27.47 KB 27.51 KB UMD_PROD
react-art.development.js -0.1% -0.1% 340.43 KB 339.94 KB 71.58 KB 71.51 KB NODE_DEV
react-art.production.min.js -0.2% -0.1% 55.25 KB 55.14 KB 16.77 KB 16.76 KB NODE_PROD
ReactART-dev.js -0.1% -0.1% 348.69 KB 348.2 KB 71.13 KB 71.06 KB FB_WWW_DEV
ReactART-prod.js -0.2% -0.1% 167.03 KB 166.73 KB 27.44 KB 27.41 KB FB_WWW_PROD

react-scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-scheduler.development.js -4.5% -2.3% 10.68 KB 10.2 KB 3.68 KB 3.6 KB UMD_DEV
react-scheduler.production.min.js -5.9% -1.5% 1.68 KB 1.58 KB 873 B 860 B UMD_PROD
react-scheduler.development.js -4.5% -2.4% 10.49 KB 10.01 KB 3.63 KB 3.55 KB NODE_DEV
react-scheduler.production.min.js -5.3% -2.0% 1.75 KB 1.66 KB 889 B 871 B NODE_PROD

Generated by 🚫 dangerJS

@flarnie flarnie merged commit 9c77ffb into facebook:master Apr 24, 2018
NE-SmallTown referenced this pull request Apr 25, 2018
* Remove the 'alwaysUseRequestIdleCallbackPolyfill' feature flag

**what is the change?:**
Removes the feature flag 'alwaysUseRequestIdleCallbackPolyfill', such
that we **always** use the polyfill for requestIdleCallback.

**why make this change?:**
We have been testing this feature flag at 100% for some time internally,
and determined it works better for React than the native implementation.
Looks like RN was overriding the flag to use the native when possible,
but since no RN products are using 'async' mode it should be safe to
switch this flag over for RN as well.

**test plan:**
We have already been testing this internally for some time.

**issue:**
internal task t28128480

* fix mistaken conditional

* Add mocking of rAF, postMessage, and initial test for ReactScheduler

**what is the change?:**
- In all tests where we previously mocked rIC or relied on native
mocking which no longer works, we are now mocking rAF and postMessage.
- Also adds a basic initial test for ReactScheduler.
NOTE -> we do plan to write headless browser tests for ReactScheduler!
This is just an initial test, to verify that it works with the mocked
out browser APIs as expected.

**why make this change?:**
We need to mock out the browser APIs more completely for the new
'ReactScheduler' to work in our tests. Many tests are depending on it,
since it's used at a low level.

By mocking the browser APIs rather than the 'react-scheduler' module, we
enable testing the production bundles. This approach is trading
isolation for accuracy. These tests will be closer to a real use.

**test plan:**
run the tests :)

**issue:**
internal task T28128480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants