A wise man once said: "React is such a good idea that we will spend the rest of the decade continuing to explore its implications and applications”.
In 2017, React Fiber was the thing in the community. In 2018, hooks – and the completely new mindset they brought along – took that role with a little help of Concurrent React.
But there are a few other big things happening out there: React Fire, React Flare and the Scheduler. These go from completely rethinking the event system to bringing cooperative scheduling to the browser environment, and much more!
In this talk, we’ll look at what are these, how they fit together with other changes and, hopefully, by the end of the talk, you'll be just as enthusiastic as I am about what's coming down the line.
Last but not least, we'll take a glimpse into the future of the Web platform.
5. 5
Guillermo Rauch, CEO @ZEIT
“React is such a good idea that we will
spend the rest of the decade
continuing to explore its implications
and applications.“
15. 15
Consists of…
• An effort to modernize React DOM
• Focused on making React better aligned with how the DOM works
• It also aims to make React smaller and faster
It brings…
• Attach events at the React root rather than the document
• Migrate from onChange to onInput and don’t polyfill it for uncontrolled components
• className → class
• React Flare
• …
DOM•REACTFIRE
16. 16
• Attaching event handlers to the document becomes an issue when embedding React apps into larger systems
• Any big application eventually faces complex edge cases related to stopPropagation interacting with non-
React code or across React roots
• The Atom editor was one of the first cases that bumped into this
DOM•REACTFIRE •ATTACHEVENTSATTHEREACTROOT
17. 17
• Stop using a different event name for what's known as input event in the DOM
• Stop polyfilling it for uncontrolled components
DOM•REACTFIRE •ONCHANGE →ONINPUT
19. 19
• Experimental React Events API (react-events)
• Necolas is the creator of react-native-web and cares a lot about cross-platform consistency
• The Event System umbrella under React Fire
DOM•REACTFLARE
20. 20
• Make it easy to build UIs that feel great on desktop and mobile, with mouse and touch, and that are accessible
• It includes declarative APIs for managing interactions
• Unlike with the current React event system, the Flare design doesn't inflate the bundle for events you don't
use
• It should allow to cut down the amount of code in UI libraries that deal with mouse and touch events
DOM•REACTFLARE
21. 21
• It includes declarative APIs for managing interactions
DOM•REACTFLARE
• useTap
• useKeyboard
• usePress
• useResponder
• useFocusManager
• listeners={…}
26. 26
• The Flare event system ended up being a too-high-level-abstraction
• As parts of the event system considered unnecessary or outdated were removed, they discovered many edge
cases where it was being very helpful and prevented bugs
• Reducing library code to re-add it several times in the application code was not the best tradeoff
• Even basic things like buttons feel very different with mouse and touch when you use events like onClick
DOM•REACTFLARE
36. 36
• Provides a scalable solution to performance
• Lets us coordinate CPU and network-bound updates
• Improves perceived performance
• It doesn’t solve React.js problems; it solves UI problems
SCHEDULING • OVERVIEW
39. 39
SCHEDULING • REACT
Concurrent React
• Allows rendering work to be paused and resumed later
• Makes tasks smaller
Scheduler
• A way to schedule work in the browser
• Unstable! API will change
42. 42
SCHEDULING • REACT
Immediate
User Blocking
Normal
Low
Idle
"Do it now" Now!
"Do it now" 250ms
"Do it soon" 5s
"Do it eventually” 10s
"Do it if you can” No timeout 🤷
43. 43
SCHEDULING • REACT
Immediate
User Blocking
Normal
Low
Idle
"Do it now" Now!
"Do it now" 250ms
"Do it soon" 5s
"Do it eventually” 10s
"Do it if you can” No timeout 🤷
first one is really sync
57. 57
SCHEDULING • REACT• DEMO
Demo recap
• Concurrent React can break long running tasks into chunks
• The scheduler allows us to prioritize important updates
59. 59
SCHEDULING • THEWEB
• Everyone should use the same scheduler
• Having more than one scheduler causes resource fighting
• Interleaving tasks with browser work (rendering, GC)
60. 60
SCHEDULING • THEWEB
We have a few scheduling primitives:
• setTimeout
• requestAnimationFrame
• requestIdleCallback
• postMessage
64. 64
SCHEDULING • THEWEB
• Developed in cooperation with React, Polymer, Ember, Google Maps, and the Web Standards Community
• Aligned with the work of the React Core Team
• Integrated directly into the event loop
69. 69
while (workQueue.length > 0) {
if (navigator.scheduling.isInputPending()) {
// Stop doing work if we have to handle an input event.
break;
}
let job = workQueue.shift();
job.execute();
}
SCHEDULING • THEWEB
70. 70
while (workQueue.length > 0) {
if (navigator.scheduling.isInputPending(['mousedown', 'keydown']))
{
// Stop doing work if we think we'll start receiving a mouse or
key event.
break;
}
let job = workQueue.shift();
job.execute();
}
SCHEDULING • THEWEB
71. 71
SCHEDULING • CONCLUSIONS
• Scheduling is necessary for responsive user interfaces
• We can solve a lot at the framework level with Concurrent React and the Scheduler
• A Web Standards proposal is in making that brins a scheduler API to the browser
94. 94
CONTROLFLOW•REACT
A component is able to suspend the
fiber it is running in by throwing a
promise, which is caught and handled
by the framework.
95. 95
CONTROLFLOW•REACT
A component is able to suspend the
fiber it is running in by throwing a
promise, which is caught and handled
by the framework.
throw-handle-resume pattern
96. 96
2016
2016
2017
2018
2019
Effect Handlers as ECMAScript proposal
CONTROLFLOW•REACT
Effect Handlers experiments (Layout)
Effect Handlers experiments (Context)
Effect Handlers as Hooks
Effect Handlers as Suspense
106. 106
• It's a reimplementation of hot reloading with full support from React
• It's originally shipping for React Native but most of the implementation is platform-independent
• The plan is to use it across the board — as a replacement for purely userland solutions (like react-hot-loader)
• Adoption requires integration with existing bundlers common on the web (e.g. Webpack, Parcel etc.)
OTHERCOOLSTUFF• FAST REFRESH
109. 109
• A new generation of hot reloading
• Changes include initial scaffolding, infrastructure, and Babel plugin implementation
OTHERCOOLSTUFF• REACTFRESH
115. 115
• ”An experimental API aimed to greatly improve server side rendering experience” – Philipp Spiess
• ”A non-GraphQL solution for composing arbitrary data logic in a parallel hierarchy to your components” – Dan
Abramov
• Probably somehow related to mapping URLs to data and views (similar to Navi)
OTHERCOOLSTUFF• REACTFLIGHT
127. 127
Guillermo Rauch, CEO @ZEIT
“React is such a good idea that we will
spend the rest of the decade
continuing to explore its implications
and applications.“
141. 141141
This is me giving a talk about Ionic on
an iOS developers meetup five years
ago telling them that Angular would be
the future.
CONCLUSIONS• THEPAST
142. 142142
This is me giving a talk about Ionic on
an iOS developers meetup five years
ago telling them that Angular would be
the future.
CONCLUSIONS• THEPAST
143. 143143
This is me giving a talk about Ionic on
an iOS developers meetup five years
ago telling them that Angular would be
the future.
CONCLUSIONS• THEPAST
144. 144144
This is me giving a talk about Ionic on
an iOS developers meetup five years
ago telling them that Angular would be
the future.
CONCLUSIONS• THEPAST