Тёмный

You Probably Shouldn't Use React.memo() 

Theo - t3․gg
Подписаться 293 тыс.
Просмотров 53 тыс.
50% 1

React.memo is great. You probably shouldn't use it. Great article TK!
Follow him! x.com/tkdodo?s=21&t=UvyVXF6GN...
Link: tkdodo.eu/blog/the-uphill-bat...
Check out my Twitch, Twitter, Discord more at t3.gg
S/O Ph4seOn3 for the awesome edit 🙏

Наука

Опубликовано:

 

4 ноя 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 172   
@TheHarryLongbottom
@TheHarryLongbottom 7 месяцев назад
if my app never renders in the first place then I don't have to worry
@himanshutripathi7441
@himanshutripathi7441 7 месяцев назад
Yes that is why I am switching back to jinja + vanilla js
@goosydev
@goosydev 7 месяцев назад
@@himanshutripathi7441 I'm sorry to hear that
@TypingHazard
@TypingHazard 7 месяцев назад
Based
@boredSoloDev
@boredSoloDev 7 месяцев назад
Same 😂
@jherr
@jherr 7 месяцев назад
C'mon, y'all get on me all the time about pronouncing Zustand as a German word, and you're gonna let Theo get away with calling it zuss-tand. RU-vid comment section I am disappointed. Very disappointed! Another great video, Theo! 😃
@DioArsya
@DioArsya 7 месяцев назад
😶
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
Soo-shtand
@mwaselal-shalabii836
@mwaselal-shalabii836 4 месяца назад
*"zoo-sh-tand"* is the way to go
@PS3centere
@PS3centere 7 месяцев назад
Theo: I love react Also Theo: don’t use any of its inbuilt features
@coolemur976
@coolemur976 7 месяцев назад
Most of React inbuilt features are outdated tho 🥺
@carebeyan
@carebeyan 7 месяцев назад
i know this is a joke. but i'll bite. *make sure you understand why you need to reach out for a specific in-built feature
@PS3centere
@PS3centere 7 месяцев назад
@@carebeyan This is true. To be fair i'm only a hobbiest and iv'e moved to sveltekit it just seems so much nicer BECAUSE I don't need 9000 npm packages just to get it to work properly
@user-oy3wj8kt4l
@user-oy3wj8kt4l 7 месяцев назад
Bro just like components in another component
@kabukitheater9046
@kabukitheater9046 5 месяцев назад
i'll be hardpressed to call use memo a 'feature'. it's a patch to fix some inherent architectural flaw in react.
@didiercatz
@didiercatz 7 месяцев назад
Can’t we just admit large parts of React suffer from bad API design (for the masses, not Facebook)
@farhanghazali4406
@farhanghazali4406 7 месяцев назад
Actual video title: You Probably Shouldn't Use React
@marc536
@marc536 7 месяцев назад
This whole conversation about 'My entire freaking app re-renders when I only update a counter... Gee whiz, I'd better use all the "Senior React Dev Tips and Tricks™" to avoid having a sluggish app!' seems to imply that the React development team has shifted a lot of their responsibilities onto the users of their framework.
@huge_letters
@huge_letters 7 месяцев назад
React has a lot of technical debt in terms of their state reactivity and rerenders approach - but you can't just deprecate this stuff at that point. And there isn't much you can do if your components are render functions(instead of builder like in other frameworks) and reactivity basically just relies on if (prevState!==newState) render() - that's why those memoization hatches exist.
@RomvnlyPlays
@RomvnlyPlays 7 месяцев назад
REACT IS A LIBRARY!
@keithjohnson6510
@keithjohnson6510 7 месяцев назад
I think the problem here is that people believe React is a full framework. I have a different view, React does 1 thing really good, it's a JSX to VDOM to DOM consolidator (of course those stages are different for Native etc), if you start expecting it to be more, that's when issues creep in. eg. `useState` been pushed up the render pipeline etc, is a massive fail. And comparisons between say Vue & React don't make sense, Vue & NextJS comparisons sure.. So yes, React have shifted the responsibility onto the users, but is that really a bad thing?. This basically allows the user to decide what state manager he likes, rather than one thrown on them by React Devs. Could you imagine if React had included Redux as it's state manager in the early days, well let's say this, I wouldn't be using it now.
@jacksonbourne
@jacksonbourne 7 месяцев назад
​@@keithjohnson6510Sure, but at some point there should be a sensible and easy-to-use default with the ability to change it in some advanced config. Even then, multiple state management tools is a terrible idea and will just result in fragmenting the ecosystem. They should have just designed it better in the first place.
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
@@RomvnlyPlays React is just an npm package!
@struggopuggo
@struggopuggo 7 месяцев назад
Things like this is why I've switched to Svelte.
@anup_5
@anup_5 3 месяца назад
Can you elaborate more?
@rafaelarantes4804
@rafaelarantes4804 7 месяцев назад
This video is really important. I think the most important part is not about react.Memo, but about reference management in a React application. From the moment you start to get objects as props, is really easy to get lost, mainly in a production app with thousands of files where you don't know which variable can be trusted to maintain a stable enough reference that you can use as a dependency of your own variable.
@HyuLilium
@HyuLilium 7 месяцев назад
Yes, but I find the video title highly exaggerated.
@pokefreak2112
@pokefreak2112 7 месяцев назад
You Probably Shouldn't Use React.
@riolly
@riolly 7 месяцев назад
I just start developing a date range picker last week and hit this problem. Super helpful insight. Thank you so much @Theo
@gro967
@gro967 7 месяцев назад
React: I have a really weird implementation of component rendering, but I give you a bunch of weird utilities to fix it on your own Vue: Let me handle that for you
@XavierGoncalves89
@XavierGoncalves89 7 месяцев назад
Back in the day, jquery didn't trigger re-renders
@thelaitas
@thelaitas 7 месяцев назад
I have been writing react code for around two years atm, and I haven't used Memo on components yet
@mpiorowski
@mpiorowski 7 месяцев назад
The fact that this discussion still exists, that Reddit posts are still debating it, and that articles are still popping up after many years just shows how React is still an overcomplicated piece of technology with a lot of pitfalls. :D
@keithjohnson6510
@keithjohnson6510 7 месяцев назад
No, it shows that how many people totally miss understand what React is & is not. If you install React and think that's all you need, then your in a world of pain. It needs at least one other lib, Jotai, Redux, Rematch, Zustand, etc etc. But whatever you do pick at least one of them. Maybe the biggest mistake React have done, is not making that point clear enough. React on it's only can only really be used for very simple apps, even a simple ToDo list is would benefit from a state lib.
@kasper4135
@kasper4135 7 месяцев назад
@@keithjohnson6510 How do you not see the issue with this?
@EdwinMartin
@EdwinMartin 7 месяцев назад
Indeed. Years ago React moved away from classes because beginner/light programmers didn’t know how to use `this`. Turns out you have to be an expert anyway because you have understand the hidden complexity.
@Momosun2018
@Momosun2018 7 месяцев назад
@@keithjohnson6510they should have the feature baked in. Seriously, state management is a pain in the you know what.
@captainlennyjapan27
@captainlennyjapan27 7 месяцев назад
React has too many “well actually, you should not” 😢
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
It's only for content most of the time
@dealloc
@dealloc 7 месяцев назад
React provides primitives. useEffect is a primitive hook that can wrap a lot of different logic depending on your use-case. That's why it has footguns, as with any lower level APIs. Use libraries that abstracts around these primitives, where performance, maintainability and simplicity matters. Or create your own abstraction for specific use-cases to make it impossible to misuse. Memo is also not unique to React and its rules are not unique to React. Any memoization implementation will effectively have the same tradeoffs. It's a caching mechanism, which requires cache invalidation. You have to make tradeoffs where needed. React already does a lot to make renders fast, so don't sweat it.
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
@@dealloc you’re right it has trade-offs, this topic deserves I bigger video on that. People in the comments are just like “alright, I guess I will never use memo or React ever in my life”
@jouebien
@jouebien 4 месяца назад
I could get 3120 elements re-rendering at 60fps with no slow down. 100% agree, If you having slow performance have a look at your overall state design.
@nizomsidiq3
@nizomsidiq3 7 месяцев назад
looks like the problem is prop drilling which passing object (and array) as props, If you are building uncontrolled component, react memo will still benefit us. by using zustand / react query, usually you will end up mixing your logic state with component state
@51Grimz
@51Grimz 7 месяцев назад
Yeah that was super helpful. I've been trying to optimize a high level state describing the config of every component and children on a page. Memorizing each component with little luck. Using redux toolkit now but I think I still fell into a trap by passing via prop. Need to surgically get each components state from the store.
@joaopslins
@joaopslins 7 месяцев назад
I'm curious, why you would pass it as a prop if you are using redux toolkit? If you use the selectors you can have memoization in the data and avoid unnecessary rerenders
@amaury_permer
@amaury_permer 7 месяцев назад
​@@joaopslinsthere are components that have to be reusable and passing data as props is the proper way to make them reusable
@51Grimz
@51Grimz 7 месяцев назад
@@joaopslins I think that's the play. Need to create a way where I can use the selector to get the props of the individual component, then pass them in as props to the reusable component. Plan is to use some sort of generic component wrapper to do that. If you know of some examples of this I am curious to see how others have implemented this.
@51Grimz
@51Grimz 7 месяцев назад
@@amaury_permer That's kind of the struggle I'm having. Want to make reusable react components to use within my react code, but be able to hook those same components into this JSON page config design model too.
@requizm
@requizm 7 месяцев назад
Wait, we misunderstood another React feature? How shocking. That's definitely not always happening in React.
@drewhjava
@drewhjava 7 месяцев назад
I mean, Solid solves all of this. You can put the state wherever it makes sense for your code and it will always render quickly.
@Helicees
@Helicees 7 месяцев назад
Correct me if i'm wrong but .. if the child element is stable .. i.e. im stable .. it shouldn't cause re-renders as a child of a memoized component.
@nazar1744
@nazar1744 7 месяцев назад
You Probably Shouldn't Use React
@matanon8454
@matanon8454 7 месяцев назад
Switching to VueJS was the best decision i could make. Not caring anymore about all this footguns makes me so productive. Love it 🥰
@saadhabashneh5587
@saadhabashneh5587 7 месяцев назад
Does Vue have jsx?
@smash3689
@smash3689 7 месяцев назад
@@saadhabashneh5587you can use vue with jsx, but it isn't the same one with react, which gets transpiled into React.createElement, but in vue the jsx code will be transpiled into vue's own virtual dom generation function - which is the "h" function, aka render function -.
7 месяцев назад
@@saadhabashneh5587 Yes, it does.
@simonhartley9158
@simonhartley9158 7 месяцев назад
​@@saadhabashneh5587 Yes it does. They recommend to default to using Vue templates instead.
@daedalus5070
@daedalus5070 7 месяцев назад
@@saadhabashneh5587 It can but its not the same as React. Better to use plain HTML/templates as it's just 1000x easier to read and manage.
@mifino
@mifino 7 месяцев назад
All this time since using react class components where PureComponent was recommended, I’ve ignorantly kept slapping memo on most of my components without thinking much of it 🤦‍♂️ thanks for the heads up
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
I don’t think that’s too bad. In the worst case scenario of wrongly using memo, like by not memoizing the component props, things should work exactly the same as if there wasn’t any memo on your app, all the components still rerendering on the DOM. And React handles that well too, not a big deal.
@laztheripper
@laztheripper 7 месяцев назад
At this point I just watch these videos to remind myself how much better life is in Svelte-land.
@matanon8454
@matanon8454 7 месяцев назад
Wait until you discover Vue ;)
@bynneh
@bynneh 7 месяцев назад
It's interesting to see how Vue handles reactivity and optimization out of the box. It's one of the reasons why I find Vue's approach elegant and less cumbersome for certain projects.
@pencilcheck
@pencilcheck 7 месяцев назад
the sad part is that their library ecosystem isn't as rich as react. A lot of components that I can find are mostly react only :\
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
Same for React, both optimizes the rendering components on the DOM, but at least it gives the developers the opportunity to prevent unnecessary renders with simpler logic, Vue just doesn't have that option.
@davidjesus8629
@davidjesus8629 7 месяцев назад
​@@pedrocruz8164You dont seem to understand that the reactivity approach of Vue never re-renders anything that you dont change. Why would you need a Vue.memo in the first place if the way reactivity works is surgical out the box, which is exactly what zustand, jotai, recoil and others propose to avoid Reacts problems.
@huge_letters
@huge_letters 7 месяцев назад
I think every other framework handles it better - React is the outsider here. Solid/Preact use signals,Angular uses observables, Vue uses proxies and getters, Svelte uses compiler. Only React just uses Object.is(=== basically)
@RafaelMagalhaes93
@RafaelMagalhaes93 7 месяцев назад
@@pencilcheck main reason there are more react libraries is because most things need a react wrapper to work inside of react as in Vue you can just use the js library for the same component it just works
@gitgudchannel
@gitgudchannel 7 месяцев назад
"Zustand" is pronounced "tsuu-shtaand" and means "state" or "condition" in German.
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
yea I heard they want to rename React to kaputt.
@vladyslavzavalykhatko467
@vladyslavzavalykhatko467 7 месяцев назад
Memoization is a simpler approach imo, unless one uses a state management library at the first place. Bringing a lib to resolve a problem that has a working solution out of the box sounds like an overkill
@artyomnomnom
@artyomnomnom 7 месяцев назад
Why should a developer ever be bothered with all this framework-internal stuff? Developers are meant to solve business problems, not to fight another framework's design flaws. A compiler should handle all the necessary optimizations, similar to what Svelte does.
@oscarljimenez5717
@oscarljimenez5717 7 месяцев назад
React Forget
@davixx1995
@davixx1995 7 месяцев назад
Yeah, another thing that bothers me is how you have to setup your editor perfectly so it suggests you the correct dependencies with useEffect/useMemo or it's gonna be really easy to mess up everything. Like, why can't the framework do that by itself? It's surprising react is still the default goto framework
@dealloc
@dealloc 7 месяцев назад
Which is part of why they are working on React Forget. Also, to have effective optimizations you have to know some internals before you can make the right tradeoff. It's the same as having to choose between data structures, depending on your use-case. You'd have to know beforehand how you'd like to store things in memory and how they are accessed. But abstracting this to try and fit it into every solution won't work, as those may require other optimization strategies. React provides primitives because the team don't think providing abstractions that work for a tiny number of people is worth the maintenance burden that comes with provided new APIs both for the maintainers, but also for users of React. Which I'd agree with.
@titidantete
@titidantete 7 месяцев назад
ive use memo for ever changing assets (3 components that able show: image, av and 3d), the expectation is not rerender by expecting just show the asset, but its rerender... so is that memo-ize problem or by using global state (zustand in my case) problem ?
@BosonCollider
@BosonCollider 7 месяцев назад
I would honestly just switch to preact signals instead of dealing with the hooks stuff to avoid recomputing things
@vinhandev
@vinhandev 6 месяцев назад
tks for sharing
@_Yolandi
@_Yolandi 7 месяцев назад
7:39 💀me as a german speaker, when Theo says "Zustand".
@Tristan-mr3pk
@Tristan-mr3pk 7 месяцев назад
How big are your tables dude? If you are rendering content you can’t see on the screen, you may consider some form of pagination or windowed rendering.
@Tristan-mr3pk
@Tristan-mr3pk 7 месяцев назад
My other solution to this is to connect to the backend and get the data from there. I’d rather be coupled across the network than to a state management system.
@usmanabdurehman97
@usmanabdurehman97 7 месяцев назад
Man. I learnt React because at the time it looked like the easiest thing you could learn and now its looking like the hardest/most complex UI Framework. What went wrong?
@choilive
@choilive 7 месяцев назад
React was supposed to be a UI library but quickly evolved (or devolved IMO) into an entire app framework due to everyone slowly pushing all of the app scope onto the browser. All the work that statically reendered apps did now is done on the frontend and then some, all while duplicating most of the backend logic. Suddenly the frontend is now an entire long lived application in itself with all of the state problems that came with it.
@fifty-plus
@fifty-plus 7 месяцев назад
React is a very leaky abstraction with a lot of footguns. Once you're aware of the low level concepts you're mostly good to go.
@seljuz
@seljuz 7 месяцев назад
Wait till you try angular
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
Just use a good state management library and you will be fine
@choilive
@choilive 7 месяцев назад
@@pedrocruz8164 this is symptomatic of the problem, why has front-end state evolved to the point where we need entire state management libraries as well?
@cashmoneyz3
@cashmoneyz3 7 месяцев назад
Wouldnt this technically be lifting state up and not lifting the content up? Because now the component with state is wrapping the content.
@RemotHuman
@RemotHuman 7 месяцев назад
Is react worth learning over something like svelte, vue, or solid, for any reason other than job market?
@matanon8454
@matanon8454 7 месяцев назад
nope, just try in a small project and see yourself. I would use Vue since its a very good middleground from ease of use and ecosystem
@DeadOce4n
@DeadOce4n 7 месяцев назад
If I have no users, does my app's rendering performance really matter?
@andrueanderson8637
@andrueanderson8637 7 месяцев назад
I've said it before but I'll say it again: the editing on these videos is super jarring. Little jump cuts after every single phrase is really hard to listen to. It disrupts the inflection in the voice and makes things harder to understand. I understand you're trying to cut out pauses and keep the video as brief as possible but I can't imagine you're saving much time by cutting out (fractions of?) seconds..
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
jenna marbles is editing the videos
@yorailevi6747
@yorailevi6747 7 месяцев назад
This is crazy to me, i don't do react but this just went over how memoization is just caching and it's not a solution for event handling, which is solved with "state management and hooks" aka observer pattern
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
React used to be an npm package, then it grew a little and became a library. A few years later it grows more and becomes a framework, and today it became something even larger than that. React is life. It's so large that if we stop using it it will kill us.
@anyadatzaklatszjutub
@anyadatzaklatszjutub 7 месяцев назад
Well deserved shoutout! TKDodo da man
@leularia
@leularia 7 месяцев назад
Zustand to the resque...
@teklife2151
@teklife2151 7 месяцев назад
awesome video theo!
@darkfoxwillie
@darkfoxwillie 7 месяцев назад
like because of the links, thanks for the sauce.
@martiananomaly
@martiananomaly 3 месяца назад
The thumbnail though
@musaiyyab
@musaiyyab 7 месяцев назад
Offtopic : Honestly, I find your thumbnails not funny anymore, became boring. May be use some new thumbnails for some time to come.
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
Women with breasts work nice on me! I click each and every time!
@abdelhameedhamdy
@abdelhameedhamdy 7 месяцев назад
What about using preact/signals as an alternative !
@dealloc
@dealloc 7 месяцев назад
That's a state management solution. But worse, since it changes React internals in order to work how it does. If those internals change with a new React update, you have no way to update it without either waiting for a patch from Preact, or patch it yourself, potentially introducing bugs that can be hard to debug.
@lescobrandon2202
@lescobrandon2202 6 месяцев назад
Use signals, problem solved.
@ZapOKill
@ZapOKill 7 месяцев назад
set playback speed to .9!
@eero8879
@eero8879 7 месяцев назад
They should just do React 2 with modern approach instead of piling more stuff to solve problems that shouldn't exist.
@z3rocodes
@z3rocodes 7 месяцев назад
Just use a 3rd party state management library.. This can all be avoided by not using reacts own state management.
@vishalsangole836
@vishalsangole836 7 месяцев назад
Thumbnail developer Theo brown
@Akhbash
@Akhbash 7 месяцев назад
Your last quote from Dominik was the only thing I didn't agree on the video. As "shorter to write" can come with less context or high cognitive overload when coding, so that for me doesn't always work, it seems as a good bet, but it can't guarantee that it won't have some bad trade-offs.
@TkDodo
@TkDodo 7 месяцев назад
I make ONE bad joke and Theo reads it on his video 😭. I wanted to say that "shorter to write" is not a good argument for anything, because we should optimize for readability first. We always read code more often than we write it. I have a blogpost on that, too. I should just stop doing jokes and stick with content I guess 😂
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
@@TkDodo are you saying $("blah") is not readable? What's there not to understand? It's a US Dollar sign, with some paranthesis and a word "blah"! Even my dog would understand it and I don't even have a dog!
@ZamirMubashir
@ZamirMubashir 7 месяцев назад
Why would highlightRows={highlight ?? []} break memoization?
@SandraWantsCoke
@SandraWantsCoke 7 месяцев назад
[] does not equal [] on each new render and {} does not equal {}, React thinks it's a new object. to prove console.log("Is this equal: ", { name: "Mike" } === { name: "Mike" })
@ImranSheikh-kg4qd
@ImranSheikh-kg4qd 7 месяцев назад
Our Codebase is memo free 😃
@pencilcheck
@pencilcheck 7 месяцев назад
most of the time, the slowness is coming from other stack, such as swr, apollo, graphql, tanstack query, trpc, etc as their default takes a long time to resolve. Once I switched to telefunc everything is showing up instantly
@seljuz
@seljuz 7 месяцев назад
What's telefunc
@pencilcheck
@pencilcheck 7 месяцев назад
also, I stopped using nextjs. I use vike instead it is basically ssr plugin for vite and it is actually very minimal and just as useful as nextjs. (the initial setup might not feel as smooth but once you get it it is actually very simple)
@EdwinMartin
@EdwinMartin 7 месяцев назад
Das ist eine ziemliche Zustand!
@betapacket
@betapacket 7 месяцев назад
You shouldn't use React at all.
@sjzz
@sjzz 7 месяцев назад
Bruh, I used it 😭😭😭
@alastairtheduke
@alastairtheduke 7 месяцев назад
One thing that I always thought, but turned out wrong is that components re-render when props change, they don't.
@user-tt3bc7yk8r
@user-tt3bc7yk8r 7 месяцев назад
isn't it?
@y0na24
@y0na24 7 месяцев назад
@@user-tt3bc7yk8rto get new props we need to rerender the component, so state changing is the main reason for rerendering, but not props changing
@lalithrockz
@lalithrockz 7 месяцев назад
​@@user-tt3bc7yk8rthey do, they also re render if the parents functions are not memoized with useCallback even if you use memo wrap to the child components.
@brangja4815
@brangja4815 7 месяцев назад
They do
@user-fu2kg4ug2q
@user-fu2kg4ug2q 7 месяцев назад
Git gud
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
Theo, please comment here that wrongly using memo is the exactly same as not using memo at all, so it's not a shot in the foot or whatever. I see a lot of apocalyptic comments on this video.
@dealloc
@dealloc 7 месяцев назад
In fact it's not just the exact same, but worse depending on how much you do it since. memoization requires storing additional copies of things in memory for caching, it will take up additional memory for no reason, which can lead to an overall bad user experience.
@TkDodo
@TkDodo 7 месяцев назад
well if it's used wrongly it's more code to write and maintain. Why would we want code that does nothing in the best case, and adds additional overhead in the worst?
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
@@dealloc I think memory is not directly tied to UX, it certainly doesn’t affect rendering performance at all.
@pedrocruz8164
@pedrocruz8164 7 месяцев назад
@@TkDodo I mean nobody should use anything wrongly ever. React memo has useful usage on specific cases, and we shouldn't just throw it out the window just because is hard to understand how to use it.
@rapzid3536
@rapzid3536 7 месяцев назад
This is 100% the sort of take you'd expect from a content creator though. People who have worked across a number of React teams of different sizes, skillsets, and project sizes might have a more nuanced opinion of this. Someone who are ultimately responsible for sorting out perf issues a team encounters might have a different recommended default approach.
@Rulito2405
@Rulito2405 7 месяцев назад
Can someone elaborate on why it is bad to pass an empty object/array as fallback option to a prop in a memoized component? Here ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Yh2eH4fXgbU.html
@Rulito2405
@Rulito2405 7 месяцев назад
Is it because an empty object/array as fallback value will always have a new reference on every render breaking memoization?
@Fan_of_Ado
@Fan_of_Ado 7 месяцев назад
Just don't use React
@alexm9104
@alexm9104 7 месяцев назад
Why we even NEED React library this days? State management? TanStack Query, Zustand, Jotai, Recoil e.t.c. (most of them are framework agnostic) are better than native React tools. Routing? Completely irrelevant to original React lib. Managed by external libs by default. JSX syntax extension? Not React exclusive. Other frameworks can have it too. What exactly React library do today? And why should we still use it and not Vue, Svelte, Angular e.t.c.?
@keithjohnson6510
@keithjohnson6510 7 месяцев назад
Correct things like Jotai do state better than React, and is the reason you use React+(state manager of choice).. Why use React?, well personally I would love to switch to SolidJS, but it would be a big change for existing apps. Never been a fan of View syntax, but what's more concerning is look at breaking changes for V3 Vue?. One things you have to give React credit for is backwards compatibility, code I've written years ago in React, will in most cases work on the latest version with minimal changes if at all, that V2 to V3 breaking changes would scare the hell out of me.
@alexm9104
@alexm9104 7 месяцев назад
@@keithjohnson6510 React in its essence is JS functions. So backwards compatibility is not an issue. And, logically, React is much easier to debug. But now no one uses just React library without other libs and addons. So all that aforementioned pros can go through the window because of some unstable library you installed years ago. Which is poses the same question: why I ever need to use React now-days and experience all those pain points?
@keithjohnson6510
@keithjohnson6510 7 месяцев назад
@@alexm9104 I gave you a few reasons. Repeating the same question won't change my answer. Also React is not just a function, it also has backwards compatibility with class based React components. And in fact still has to be used for certain things like Error boundaries. If you mean why start a new project in React, then yes, maybe going SolidJS might be an option, but you still have the issue of the massive eco system React brings with it, that Solid currently does not have. But saying that, I don't have any pain points with React, so I wouldn't experience them anyway, so sticking with React seems fine to me. YMMV
@alexm9104
@alexm9104 7 месяцев назад
@@keithjohnson6510 ok. Just remind you, JS has no "traditional" classes. Classes in JavaScript are syntactic sugar for constructor functions. With extra optimization, maybe idk. That's all. I'm done.
@keithjohnson6510
@keithjohnson6510 7 месяцев назад
@@alexm9104 Was there a point you was making there?. Regardless if you class JS classes as true classes or not, it's still rather nice a React component written uses classes, still works in the latest version of React. That cannot be said for a lot libs out there, breaking changes can sometimes be a pain in the but.
@AJ-wf1vh
@AJ-wf1vh 7 месяцев назад
You're meant to use react memo to memoize the output of slow functions In this case, its easy to define the dependencies of the function to optimize only the slow part of a component Ive never thought of wrapping a whole component in a memo call as an optimization It sounds like a terrible idea and reeks of bootcamp vibes React render functions are supposed to be fast to run. If an app is large enough where this is not the case anymore, perhaps the problem is using react itself, not memo
@ShawnShaddock
@ShawnShaddock 7 месяцев назад
Every time I see a clickbait thumbnail I will not only not watch the video, I will dislike it too, for being clickbait.
@sukritsaha5632
@sukritsaha5632 7 месяцев назад
Yo theo. Love your content ❤.
@deepjyotideb1173
@deepjyotideb1173 7 месяцев назад
react is not slow, you are slow
@hariharansreenivas6752
@hariharansreenivas6752 7 месяцев назад
Firsttt
@yonnierenton6177
@yonnierenton6177 7 месяцев назад
Howdy love your stuff!. preactjs/signals seems epic ?
@orderandchaos_at_work
@orderandchaos_at_work 7 месяцев назад
You Probably Shouldn't Use React.
Далее
Mastering React Memo
26:56
Просмотров 132 тыс.
React Wasn't Built For The Web
12:43
Просмотров 178 тыс.
♀ 🔁 ♂ = ...❓ #OC #늦잠 #vtuber
00:12
Просмотров 1,6 млн
СЕРГЕИЧ ОПОЗДАЛ #большоешоу
00:58
Oh no, I think I like this
6:58
Просмотров 127 тыс.
React + Servers = Confusion
20:30
Просмотров 40 тыс.
Cool Tools I’ve Been Using Lately
23:11
Просмотров 165 тыс.
HTMX Sucks
25:16
Просмотров 92 тыс.
My Favorite State Manager Is...URLs?
6:29
Просмотров 68 тыс.
The Story of React
10:05
Просмотров 246 тыс.
What is React.memo - It's not useMemo
15:29
Просмотров 8 тыс.
React's New Controversial Override
13:02
Просмотров 51 тыс.
The Neuralink "Lossless" Compression Wars
37:04
Просмотров 49 тыс.