Upgrade to Pro — share decks privately, control downloads, hide ads and more …

🇮🇹 reactjsday 2024

🇮🇹 reactjsday 2024

A Decade: React’s Rhapsody of Life

Join me in celebrating the decade-long journey of React—a framework that has revolutionized front-end development.

Despite all the initial skepticism around aspects like JSX, it became one of our favorite tools. We'll explore this and other "trouble in paradise” moments!

Looking ahead, we'll discuss ongoing efforts like the Activity component, optimistic state updates, and more advanced stuff, like the optimization compiler and the recent improvements to React Native's JS engine.

Let's embrace a decade of React and the endless possibilities it holds!

Matheus Albuquerque

October 25, 2024
Tweet

More Decks by Matheus Albuquerque

Other Decks in Programming

Transcript

  1. THIS TALK IS ABOUT… OUR STORY WITH REACT DIVERGING PATHS

    BEFORE REACT MODERN REACT THE FUTURE EARLY YEARS TROUBLE IN PARADISE SOC PERFORMANCE GOLDEN YEARS JSX
  2. THE PAST: THE WEB — THE FORMATION OF FRAMEWORK WAVES

    FROM THE EPICENTER • SARAH DRASNER
  3. THE PAST: BOLTJS var CarView = require('javelin/core').createClass({ name: 'CarView', extend:

    require('container').Container, properties: { wheels: 4, }, declare: function() { return { childViews: [ { content: 'I have ' }, { ref: 'wheelView' }, { content: ' wheels' } ] }; }, setWheels: function(wheels) { this.findRef('wheelView').setContent(wheels); }, getWheels: function() { return this.findRef('wheelView').getContent(); }, }); var car = new CarView(); car.setWheels(3); car.placeIn(document.body); — OUR FIRST 50,000 STARS • CHRISTOPHER CHEDEAU
  4. THE PAST: BOLTJS ↝ CLIENT-SIDE MVC FRAMEWORK. ↝ COMBINED EXISTING

    TOOLS TO HANDLE THE COMPLEX INTERACTIVITY OF PRIMITIVE FACEBOOK TIMELINES, CHAT, NEWS FEEDS, AND OTHER ADVANCED APPLICATIONS. ↝ INTRODUCED SOME APIS AND FEATURES THAT WOULD EVENTUALLY MAKE THEIR WAY INTO REACT INCLUDING render, createClass, AND refs. — OUR FIRST 50,000 STARS • CHRISTOPHER CHEDEAU (@VJEUX)
  5. THE PAST: FAXJS ↝ SOLVED THE SAME PROBLEMS IN A

    VERY DIFFERENT WAY. ↝ MUCH MORE FUNCTIONAL; WITH NO MVC ARCHITECTURE. ↝ INTRODUCED THE CONCEPT OF RE-RENDERING WHEN SOMETHING IN THE UI HAS CHANGED. ↝ FUNDAMENTALS WERE BORN: PROPS, STATE AND THE BASIC CONCEPT OF COMPONENTS. — OUR FIRST 50,000 STARS • CHRISTOPHER CHEDEAU (@VJEUX)
  6. THE PAST: XHP function :example:hello(attrib, children) { return ( <div

    class="special"> <h1>Hello, World!</h1> {children} </div> ); } function jsx_example_hello(attrib, children) { return ( S.create("div", {"class": "special"}, [ S.create("h1", {}, ["Hello, World!"]), children ] ); } ↝
  7. AFTER REACT DECLARATIVE VIEWS STATEFUL RENDERING CLASSES MVC MVVM COMPONENT

    DRIVEN JSX PREDICTABLE* RENDERING SO MUCH BETTER THAN THE GIVEN ALTERNATIVES ↝
  8. “With React you can build applications without even thinking about

    performance and the default state is fast.” Pete Hunt (2013)
  9. Guillermo Rauch (2015) “With this model in place, the programmer

    is thus relieved from the burden of specifying the transition between states (or transformation) of the UI over time.”
  10.  Dan Abramov (2015) “I’ve seen React misunderstood by smart people

    more often than any other JavaScript library. React is packed with ideas that were radical at the time of its introduction. This created an air of controversy that still hasn’t quite dissolved.”
  11.  Dan Abramov (2015) “After a year of using React and

    observing people learning it, I can say that the best parts of React are not the ones that made it famous. They’re not virtual DOM, custom event system, server rendering or JSX. Rather, they are a few boring, old and powerful ideas.”
  12. A DECADE: REACT’S RHAPSODY OF LIFE / TROUBLE IN PARADISE

    #1 of 8 SOFTWARE DEVELOPMENT CONTINUALLY GOES THROUGH CYCLES.
  13. A DECADE: REACT’S RHAPSODY OF LIFE / TROUBLE IN PARADISE

    #1 of 8 SOFTWARE DEVELOPMENT CONTINUALLY GOES THROUGH CYCLES.
  14. A DECADE: REACT’S RHAPSODY OF LIFE / TROUBLE IN PARADISE

    #1 of 8 AND SO DO TROUBLE IN PARADISE MOMENTS. WHAT’S DIFFERENT NOW? THROUGH CYCLES.
  15. A DECADE: REACT’S RHAPSODY OF LIFE / TROUBLE IN PARADISE

    REACT PUSHED US TO THE FUTURE. #2 of 8
  16. REACT PUSHED US TO THE FUTURE OTHER FRAMEWORKS JSX /

    VIRTUAL DOM / HMR + FAST REFRESH NAT
  17. REACT PUSHED US TO THE FUTURE OTHER PLATFORMS FLUTTER /

    JETPACK COMPOSE / LITHO / SWIFTUI / COMPONENTKIT / YOGA LAYOUT / RESWIFT *
  18. REACT FORGET COMPILER ↝ IMPROVE THE RENDERING PERFORMANCE BY AUTOMATICALLY

    GENERATING THE EQUIVALENT OF useMemo, useCallback, AND memo CALLS. ↝ MINIMIZE THE COST OF RE-RENDERING WHILE RETAINING REACT’S PROGRAMMING MODEL. ↝ AUTOMATIC REACTIVITY COMPILER.
  19. OFFSCREEN ACTIVITY ↝ RENDERING IN THE BACKGROUND WITH NO ADDITIONAL

    PERFORMANCE OVERHEAD. ↝ IT DOESN'T MOUNT UNTIL THE COMPONENT BECOMES VISIBLE AND ITS EFFECTS ARE NOT FIRED. ↝ TOGGLE THE VISIBILITY WITHOUT LOSING THE STATE. ↝ INTEGRATED INTO ROUTERS AND OTHER UI LIBRARIES.
  20. OFFSCREEN ACTIVITY ↝ ROUTERS CAN PRE-RENDER SCREENS IN THE BACKGROUND

    SO THAT THEY’RE INSTANTLY AVAILABLE. ↝ TAB SWITCHING CAN PRESERVE THE STATE OF HIDDEN TABS, SO THE USER CAN SWITCH BETWEEN THEM WITHOUT LOSING THEIR PROGRESS. ↝ A VIRTUALIZED LIST CAN PRERENDER ADDITIONAL ROWS ABOVE AND BELOW THE VISIBLE WINDOW.
  21. SUSPENSE FOR CPU-BOUND TREES ↝ FORCES A FALLBACK ON THE

    INITIAL RENDER REGARDLESS OF WHETHER SOMETHING IS SUSPENDED. ↝ DURING THE INITIAL MOUNT, REACT WILL SKIP OVER EXPENSIVE TREES BY RENDERING A PLACEHOLDER. ↝ IT HELPS UNBLOCK THE INITIAL SKELETON FOR THE NEW SCREEN.
  22. OPTIMISTIC STATE UPDATES const [optimisticState, setOptimisticLikes] = useOptimistic( { likes,

    isLiked }, (state, action: "LIKE" | "DISLIKE") = > { if (action === "LIKE") { return { likes: state.likes + 1, isLiked: true }; } else { return { likes: state.likes - 1, isLiked: false }; } }, );
  23. TRANSITION TRACING ↝ USE THE PROFILER API AND DEVTOOLS PROFILER/

    TIMELINE TO WATCH FOR PERFORMANCE REGRESSIONS FOR SPECIFIC TRANSITIONS. ↝ DETECT WHEN TRANSITIONS BECOME SLOWER AND INVESTIGATE WHY THEY MAY BE SLOW. ↝ A NEW VERSION OF THE INTERACTION TRACING API.
  24. TRANSITION TRACING function App() { const user = getViewingUser(); const

    [pageName, setPageName] = useState("homefeed"); const onNavigate = (pageName) = > { startTransition(() = > setPageName(pageName), { name: pageName }); }; return ( <> <NavBar onNavigate={onNavigate} /> <Page name={pageName} id={user.id} /> </> ); } — TRANSITION TRACING API RFC
  25. TRANSITION TRACING const onTransitionStart = (transitionName, startTime) = > .

    . . ; const onTransitionComplete = (transitionName, startTime, endTime) = > . . . ; const onTransitionProgress = (transitionName, startTime, currentTime, pendingSuspenseBoundaries) = > . . . ; const root = React.createRoot(container, { transitionCallbacks: { onTransitionStart, onTransitionComplete, onTransitionProgress, }, }); — TRANSITION TRACING API RFC
  26. TRANSITION TRACING function Profile({ id }) { return ( <TracingMarker

    name="profile"> <Suspense fallback={<LoadingSpinner />}> <ProfileHeader id={id} /> <TracingMarker name="profile:photo-feed"> <div>Photos</div> <Suspense fallback={<LoadingFeed />}> <PhotoFeed /> </Suspense> </TracingMarker> <TracingMarker name="profile:profile-feed"> <div>Profile Feed</div> <Suspense fallback={<LoadingFeed />}> <ProfileFeed /> </Suspense> </TracingMarker> </Suspense> </TracingMarker> ); } — TRANSITION TRACING API RFC
  27. STATIC HERMES ↝ MODIFIES SOME JS SEMANTICS TO ALLOW EFFICIENT

    SOUND TYPING. ↝ BRIDGES PREDICTABLE C PERFORMANCE WITH JS USABILITY VIA NATIVE AOT COMPILATION. ↝ MIX AND MATCH BYTE-CODE AND NATIVE CODE BASED ON YOUR NEEDS.
  28. REACT STRICT DOM ↝ OPPOSITE APPROACH TO react-native-web. ↝ SMALL

    POLYFILLS RESPONSIBLE FOR TRANSLATING ITS APIS TO REACT-NATIVE AND REACT-DOM PRIMITIVES. ↝ LESS OVERHEAD WHEN RUNNING IN BROWSERS. ↝ POWERED BY STYLEX.
  29. A DECADE: REACT’S RHAPSODY OF LIFE / THE FUTURE /

    REACT NATIVE / REACT STRICT DOM
  30. REACT STRICT DOM: BEFORE — RFC: REACT DOM FOR NATIVE

    (REDUCE API FRAGMENTATION) #496 • NICOLAS GALLAGHER
  31. REACT STRICT DOM: BEFORE — RFC: REACT DOM FOR NATIVE

    (REDUCE API FRAGMENTATION) #496 • NICOLAS GALLAGHER
  32. REACT STRICT DOM: AFTER — RFC: REACT DOM FOR NATIVE

    (REDUCE API FRAGMENTATION) #496 • NICOLAS GALLAGHER
  33. A DECADE: REACT’S RHAPSODY OF LIFE / LESSONS LEARNED #3

    of 8 REACT IS A DEMOCRATIC AGENT FOR CS KNOWLEDGE IN OUR REALM. DSLs, COMPILERS, CONCURRENCY, FIBERS, EFFECT HANDLERS, IMMUTABILITY… OH MY!
  34. A DECADE: REACT’S RHAPSODY OF LIFE / LESSONS LEARNED #4

    of 8 A DOESN'T NECESSARILY IMPLY B. THERE'S NO SILVER BULLET. IDENTIFY YOUR CORE METRICS.
  35. A DECADE: REACT’S RHAPSODY OF LIFE / LESSONS LEARNED #5

    of 8 JSX CREATED A SIMILAR FEELING AMONG DEVELOPERS WORLDWIDE. …IT WAS GOING AGAINST SO MANY BEST PRACTICES THAT IT COULDN'T BE CONSIDERED A GOOD IDEA.
  36. A DECADE: REACT’S RHAPSODY OF LIFE / LESSONS LEARNED #6

    of 8 REACT IS STILL GOOD ENOUGH FOR MOST OF US. NOTHING IS INHERENTLY BROKEN ABOUT IT. ALSO, IT WILL NEED SOMETHING A LOT BETTER THAN REACT TO REPLACE IT. AND WE’RE NOT THERE (YET).
  37. Guillermo Rauch (2015) “In general, comparing libraries or frameworks in

    terms of features seems inferior to examining the model it imposes on the programmer. The latter will inform you about how well the code will fare over time as the product matures and the team grows, but the former won’t. It will also empower you to foresee what the evolutionary path of the technology looks like.”
  38.  Dan Abramov (2015) “Now that we’re not surprised by virtual

    DOM anymore and it is being adopted by other frameworks and libraries, we can focus on examining React’s true strengths: composition, unidirectional data fl ow, freedom from DSLs, explicit mutation and static mental model.”
  39. A DECADE: REACT’S RHAPSODY OF LIFE / LESSONS LEARNED REPORTS

    OF A CERTAIN TOOL'S DEATH ARE MOSTLY EXAGGERATED. OUTRAGEOUS CLAIMS, LACK OF EVIDENCE AND JUSTIFICATIONS, AND MORE! #7 of 8
  40. — REACT I LOVE YOU, BUT YOU'RE BRINGING ME DOWN

    • FRANÇOIS ZANINOTTO “REACT IS DYING”
  41. A DECADE: REACT’S RHAPSODY OF LIFE / LESSONS LEARNED DON'T

    ALWAYS TRUST SPECULATIONS AND PREDICTIONS! AGAIN… REPORTS OF A CERTAIN TOOL'S DEATH ARE MOSTLY EXAGGERATED. #8 of 8
  42. THIS IS ME, TEN YEARS AGO, SHOWCASING IONIC AT AN

    IOS DEVELOPERS MEETUP TELLING THEM THAT ANGULAR WOULD BE THE FUTURE OF MOBILE DEVELOPMENT.
  43. ↑ FEEDBACK WELCOME! Matheus Albuquerque ↝ 𝕏 ythecombinator ↝ 👨💻

    Staff SWE @ Medallia ↝ ⚡ Google Developer Expert