React without memo
Channel:React Conf · Length:12:01 · Published:2021-12-09 · Views:150212
Summary
A React Conf talk by Xuan Huang previewing React Forget, a compiler that automatically memoizes components. It argues for making memoization the default so developers need not write useMemo or useCallback by hand.
Why HN recommends it
Shared in discussions of useCallback and memoization as the first look at where React was heading with an auto-memoizing compiler.
I wanted to share this talk given at a recent React Conf — HN, 2022
Web development · Software performance & optimization · Compilers, interpreters & program analysis
Subtitles (excerpt)
(electronic music) - Hey, what's up folks? I'm Xuan. I'm a Software engineer at Meta. So today, I wanna talk about React and memoization. Here I have yet another TodoList. You know as JavaScript developers we just really, really love TodoLists. So, we enjoy the simplicity of the React code here, until we will open up the Java tools and we realize whenever we add a todo, or talk about todo, all the added todo is actually getting rerendered as well. The badge here shows how many times each todo has been rerendered. To fix this, what we usually do is to wrap the to-do component in React to memo. (keyboard clicks) But don't forget the handleChange is recreated on every render. So we're better also wrap that in useCallback. Now, when we add a todo, or toggle a todo, no other todos are getting rerendered. That's fixed. But, this is going to be a moving target as the app scales up. So later, we wanna build an even better TodoList. First, we wanna pass down visibility prop, so we can use it to call getfiltered functions to filter our TodoList. Then we needed a second prop, then the themeColor, so users can pick a color to theme their user interface. If we try this code out, it works, but the app feels pretty laggy
On Hacker News
For those pushing back, I wanted to share this talk given at a recent React Conf: [VIDEO] The idea (still just an internal prototype) is that one day your compiler might automatically memoize all React components and intermediate values for you. It obviously would be great to skip all the syntax noise, as well as the linter-enforced rules around correctly maintaining dependency arrays, etc. But I… — brundolf, 2022-08
There isn't much info out there yet, but this video is a small preview: [VIDEO] The latest update is mentioned in the March 2023 blog post: [LINK] — matvp, 2023-05
I agree that the typescript team should consider using the compiler to extend javascript rather than just supplement it with types. Like you said, there are technically parts of typescript that don't have a direct corollary in js (enums/namespaces), so why not take it a step further and add some of the features that js is missing? The only example where they've really taken that next step is with… — ksbrooksjr, 2022-10
Related videos
- Painting a Character with Maths · Inigo Quilez · 24:46
- My descent into America's neo-Nazi movement & how I got out | Christian Picciolini | TEDxMileHigh · TEDx Talks · 20:31
- How Python was Shaped by leaky Internals, Armin Ronacher, Flask framework · Видео с мероприятий {speach! · 49:55
- What the heck is the event loop anyway? | Philip Roberts | JSConf EU · JSConf · 26:52
- Rich Harris - Rethinking reactivity · You Gotta Love Frontend · 36:45
- CppCon 2015: Andrei Alexandrescu “std::allocator...” · CppCon · 1:12:27
- Lexical Scanning in Go - Rob Pike · GoogleFOSSSydney · 51:17
- William Byrd on "The Most Beautiful Program Ever Written" [PWL NYC] · PapersWeLove · 1:31:05
- Preventing the Collapse of Civilization / Jonathan Blow (Thekla, Inc) · DevGAMM · 1:02:41
- "Performance Matters" by Emery Berger · Strange Loop Conference · 42:15
- Crockford on JavaScript - Volume 1: The Early Years · YUI Library · 1:42:08
- RailsConf 2016 - Turbolinks 5: I Can’t Believe It’s Not Native! by Sam Stephenson · Confreaks · 37:37
- The Thirty Million Line Problem · Molly Rocket · 1:48:55
- CppCon 2017: Matt Kulukundis “Designing a Fast, Efficient, Cache-friendly Hash Table, Step by Step” · CppCon · 59:33
- Erlang Factory 2014 - That's 'Billion' with a 'B': Scaling to the Next Level at WhatsApp · Erlang Solutions · 49:15
- JavaScript: The Good Parts · Google TechTalks · 1:03:47