You Probably Shouldn't Use React.memo()

2023 ж. 4 Қар.
51 853 Рет қаралды

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 🙏

Пікірлер
  • if my app never renders in the first place then I don't have to worry

    @TheHarryLongbottom@TheHarryLongbottom5 ай бұрын
    • Yes that is why I am switching back to jinja + vanilla js

      @himanshutripathi7441@himanshutripathi74415 ай бұрын
    • @@himanshutripathi7441 I'm sorry to hear that

      @goosydev@goosydev5 ай бұрын
    • Based

      @TypingHazard@TypingHazard5 ай бұрын
    • Same 😂

      @boredSoloDev@boredSoloDev5 ай бұрын
  • 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. KZhead comment section I am disappointed. Very disappointed! Another great video, Theo! 😃

    @jherr@jherr5 ай бұрын
    • 😶

      @DioArsya@DioArsya5 ай бұрын
    • Soo-shtand

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
    • *"zoo-sh-tand"* is the way to go

      @mwaselal-shalabii836@mwaselal-shalabii8362 ай бұрын
  • Theo: I love react Also Theo: don’t use any of its inbuilt features

    @PS3centere@PS3centere5 ай бұрын
    • Most of React inbuilt features are outdated tho 🥺

      @coolemur976@coolemur9765 ай бұрын
    • 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

      @carebeyan@carebeyan5 ай бұрын
    • @@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

      @PS3centere@PS3centere5 ай бұрын
    • Bro just like components in another component

      @user-oy3wj8kt4l@user-oy3wj8kt4l5 ай бұрын
    • i'll be hardpressed to call use memo a 'feature'. it's a patch to fix some inherent architectural flaw in react.

      @kabukitheater9046@kabukitheater90464 ай бұрын
  • 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.

    @marc536@marc5365 ай бұрын
    • 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.

      @huge_letters@huge_letters5 ай бұрын
    • REACT IS A LIBRARY!

      @RomvnlyPlays@RomvnlyPlays5 ай бұрын
    • 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.

      @keithjohnson6510@keithjohnson65105 ай бұрын
    • ​@@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.

      @jacksonbourne@jacksonbourne5 ай бұрын
    • @@RomvnlyPlays React is just an npm package!

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • 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.

    @rafaelarantes4804@rafaelarantes48045 ай бұрын
    • Yes, but I find the video title highly exaggerated.

      @HyuLilium@HyuLilium5 ай бұрын
  • Can’t we just admit large parts of React suffer from bad API design (for the masses, not Facebook)

    @didiercatz@didiercatz5 ай бұрын
  • Actual video title: You Probably Shouldn't Use React

    @farhanghazali4406@farhanghazali44065 ай бұрын
  • I just start developing a date range picker last week and hit this problem. Super helpful insight. Thank you so much @Theo

    @riolly@riolly5 ай бұрын
  • Things like this is why I've switched to Svelte.

    @struggopuggo@struggopuggo5 ай бұрын
    • Can you elaborate more?

      @anup_5@anup_52 ай бұрын
  • You Probably Shouldn't Use React.

    @pokefreak2112@pokefreak21125 ай бұрын
  • Back in the day, jquery didn't trigger re-renders

    @XavierGoncalves89@XavierGoncalves895 ай бұрын
  • 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

    @gro967@gro9675 ай бұрын
  • 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.

    @51Grimz@51Grimz5 ай бұрын
    • 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

      @joaopslins@joaopslins5 ай бұрын
    • ​@@joaopslinsthere are components that have to be reusable and passing data as props is the proper way to make them reusable

      @amaury_permer@amaury_permer5 ай бұрын
    • @@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@51Grimz5 ай бұрын
    • @@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.

      @51Grimz@51Grimz5 ай бұрын
  • I have been writing react code for around two years atm, and I haven't used Memo on components yet

    @thelaitas@thelaitas5 ай бұрын
  • 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

    @nizomsidiq3@nizomsidiq35 ай бұрын
  • 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.

    @Helicees@Helicees5 ай бұрын
  • 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

    @mpiorowski@mpiorowski5 ай бұрын
    • 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.

      @keithjohnson6510@keithjohnson65105 ай бұрын
    • @@keithjohnson6510 How do you not see the issue with this?

      @kasper4135@kasper41355 ай бұрын
    • 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.

      @EdwinMartin@EdwinMartin5 ай бұрын
    • @@keithjohnson6510they should have the feature baked in. Seriously, state management is a pain in the you know what.

      @Momosun2018@Momosun20185 ай бұрын
  • 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.

    @jouebien@jouebien2 ай бұрын
  • React has too many “well actually, you should not” 😢

    @captainlennyjapan27@captainlennyjapan275 ай бұрын
    • It's only for content most of the time

      @pedrocruz8164@pedrocruz81645 ай бұрын
    • 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.

      @dealloc@dealloc5 ай бұрын
    • @@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”

      @pedrocruz8164@pedrocruz81645 ай бұрын
  • Switching to VueJS was the best decision i could make. Not caring anymore about all this footguns makes me so productive. Love it 🥰

    @matanon8454@matanon84545 ай бұрын
    • Does Vue have jsx?

      @saadhabashneh5587@saadhabashneh55875 ай бұрын
    • @@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 -.

      @smash3689@smash36895 ай бұрын
    • @@saadhabashneh5587 Yes, it does.

      @ZsoltJuranyi@ZsoltJuranyi5 ай бұрын
    • ​@@saadhabashneh5587 Yes it does. They recommend to default to using Vue templates instead.

      @simonhartley9158@simonhartley91585 ай бұрын
    • @@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.

      @daedalus5070@daedalus50705 ай бұрын
  • 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

    @mifino@mifino5 ай бұрын
    • 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.

      @pedrocruz8164@pedrocruz81645 ай бұрын
  • tks for sharing

    @vinhandev@vinhandev4 ай бұрын
  • 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 ?

    @titidantete@titidantete5 ай бұрын
  • awesome video theo!

    @teklife2151@teklife21515 ай бұрын
  • 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.

    @bynneh@bynneh5 ай бұрын
    • 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 :\

      @pencilcheck@pencilcheck5 ай бұрын
    • 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.

      @pedrocruz8164@pedrocruz81645 ай бұрын
    • ​@@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.

      @davidjesus8629@davidjesus86295 ай бұрын
    • 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)

      @huge_letters@huge_letters5 ай бұрын
    • @@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

      @RafaelMagalhaes93@RafaelMagalhaes935 ай бұрын
  • 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.

    @drewhjava@drewhjava5 ай бұрын
  • Is react worth learning over something like svelte, vue, or solid, for any reason other than job market?

    @RemotHuman@RemotHuman5 ай бұрын
    • 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

      @matanon8454@matanon84545 ай бұрын
  • Well deserved shoutout! TKDodo da man

    @anyadatzaklatszjutub@anyadatzaklatszjutub5 ай бұрын
  • Wait, we misunderstood another React feature? How shocking. That's definitely not always happening in React.

    @requizm@requizm5 ай бұрын
  • If I have no users, does my app's rendering performance really matter?

    @DeadOce4n@DeadOce4n5 ай бұрын
  • I would honestly just switch to preact signals instead of dealing with the hooks stuff to avoid recomputing things

    @BosonCollider@BosonCollider5 ай бұрын
  • 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-mr3pk5 ай бұрын
    • 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.

      @Tristan-mr3pk@Tristan-mr3pk5 ай бұрын
  • 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.

    @artyomnomnom@artyomnomnom5 ай бұрын
    • React Forget

      @oscarljimenez5717@oscarljimenez57175 ай бұрын
    • 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

      @davixx1995@davixx19955 ай бұрын
    • 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.

      @dealloc@dealloc5 ай бұрын
  • 7:39 💀me as a german speaker, when Theo says "Zustand".

    @_Yolandi@_Yolandi5 ай бұрын
  • "Zustand" is pronounced "tsuu-shtaand" and means "state" or "condition" in German.

    @gitgudchannel@gitgudchannel5 ай бұрын
    • yea I heard they want to rename React to kaputt.

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • You Probably Shouldn't Use React

    @nazar1744@nazar17445 ай бұрын
  • like because of the links, thanks for the sauce.

    @darkfoxwillie@darkfoxwillie5 ай бұрын
  • 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

    @vladyslavzavalykhatko467@vladyslavzavalykhatko4675 ай бұрын
  • At this point I just watch these videos to remind myself how much better life is in Svelte-land.

    @laztheripper@laztheripper5 ай бұрын
    • Wait until you discover Vue ;)

      @matanon8454@matanon84545 ай бұрын
  • Wouldnt this technically be lifting state up and not lifting the content up? Because now the component with state is wrapping the content.

    @cashmoneyz3@cashmoneyz35 ай бұрын
  • What about using preact/signals as an alternative !

    @abdelhameedhamdy@abdelhameedhamdy5 ай бұрын
    • 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.

      @dealloc@dealloc5 ай бұрын
  • 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

    @yorailevi6747@yorailevi67475 ай бұрын
  • Zustand to the resque...

    @leularia@leularia5 ай бұрын
  • 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..

    @andrueanderson8637@andrueanderson86375 ай бұрын
    • jenna marbles is editing the videos

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • The thumbnail though

    @martiananomaly@martiananomaly2 ай бұрын
  • 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.

    @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • Offtopic : Honestly, I find your thumbnails not funny anymore, became boring. May be use some new thumbnails for some time to come.

    @musaiyyab@musaiyyab5 ай бұрын
    • Women with breasts work nice on me! I click each and every time!

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • 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?

    @codinggalore@codinggalore5 ай бұрын
    • 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.

      @choilive@choilive5 ай бұрын
    • 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.

      @fifty-plus@fifty-plus5 ай бұрын
    • Wait till you try angular

      @FyreGaming@FyreGaming5 ай бұрын
    • Just use a good state management library and you will be fine

      @pedrocruz8164@pedrocruz81645 ай бұрын
    • @@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?

      @choilive@choilive5 ай бұрын
  • Why would highlightRows={highlight ?? []} break memoization?

    @ZamirMubashir@ZamirMubashir5 ай бұрын
    • [] 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" })

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • 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.

    @Akhbash@Akhbash5 ай бұрын
    • 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 😂

      @TkDodo@TkDodo5 ай бұрын
    • @@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!

      @SandraWantsCoke@SandraWantsCoke5 ай бұрын
  • Just use a 3rd party state management library.. This can all be avoided by not using reacts own state management.

    @z3rocodes@z3rocodes5 ай бұрын
  • set playback speed to .9!

    @ZapOKill@ZapOKill5 ай бұрын
  • Yo theo. Love your content ❤.

    @sukritsaha5632@sukritsaha56325 ай бұрын
  • 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

    @pencilcheck@pencilcheck5 ай бұрын
    • What's telefunc

      @FyreGaming@FyreGaming5 ай бұрын
    • 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)

      @pencilcheck@pencilcheck5 ай бұрын
  • Thumbnail developer Theo brown

    @vishalsangole836@vishalsangole8365 ай бұрын
  • Our Codebase is memo free 😃

    @ImranSheikh-kg4qd@ImranSheikh-kg4qd5 ай бұрын
  • They should just do React 2 with modern approach instead of piling more stuff to solve problems that shouldn't exist.

    @eero8879@eero88795 ай бұрын
  • Das ist eine ziemliche Zustand!

    @EdwinMartin@EdwinMartin5 ай бұрын
  • Use signals, problem solved.

    @lescobrandon2202@lescobrandon22025 ай бұрын
  • Bruh, I used it 😭😭😭

    @sjzz@sjzz5 ай бұрын
  • One thing that I always thought, but turned out wrong is that components re-render when props change, they don't.

    @alastairtheduke@alastairtheduke5 ай бұрын
    • isn't it?

      @user-tt3bc7yk8r@user-tt3bc7yk8r5 ай бұрын
    • @@user-tt3bc7yk8rto get new props we need to rerender the component, so state changing is the main reason for rerendering, but not props changing

      @y0na24@y0na245 ай бұрын
    • ​@@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.

      @lalithrockz@lalithrockz5 ай бұрын
    • They do

      @brangja4815@brangja48155 ай бұрын
    • Git gud

      @user-fu2kg4ug2q@user-fu2kg4ug2q5 ай бұрын
  • You shouldn't use React at all.

    @betapacket@betapacket5 ай бұрын
  • 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.

    @pedrocruz8164@pedrocruz81645 ай бұрын
    • 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.

      @dealloc@dealloc5 ай бұрын
    • 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?

      @TkDodo@TkDodo5 ай бұрын
    • @@dealloc I think memory is not directly tied to UX, it certainly doesn’t affect rendering performance at all.

      @pedrocruz8164@pedrocruz81645 ай бұрын
    • @@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.

      @pedrocruz8164@pedrocruz81645 ай бұрын
    • 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.

      @rapzid3536@rapzid35365 ай бұрын
  • 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 kzhead.info/sun/jMxrlaxsnYqdlY0/bejne.html

    @Rulito2405@Rulito24055 ай бұрын
    • Is it because an empty object/array as fallback value will always have a new reference on every render breaking memoization?

      @Rulito2405@Rulito24055 ай бұрын
  • 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.?

    @alexm9104@alexm91045 ай бұрын
    • 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.

      @keithjohnson6510@keithjohnson65105 ай бұрын
    • @@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?

      @alexm9104@alexm91045 ай бұрын
    • @@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

      @keithjohnson6510@keithjohnson65105 ай бұрын
    • @@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.

      @alexm9104@alexm91045 ай бұрын
    • @@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.

      @keithjohnson6510@keithjohnson65105 ай бұрын
  • Every time I see a clickbait thumbnail I will not only not watch the video, I will dislike it too, for being clickbait.

    @ShawnShaddock@ShawnShaddock5 ай бұрын
  • Just don't use React

    @Fan_of_Ado@Fan_of_Ado5 ай бұрын
  • 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

    @AJ-wf1vh@AJ-wf1vh5 ай бұрын
  • react is not slow, you are slow

    @deepjyotideb1173@deepjyotideb11735 ай бұрын
  • Firsttt

    @hariharansreenivas6752@hariharansreenivas67525 ай бұрын
  • Howdy love your stuff!. preactjs/signals seems epic ?

    @yonnierenton6177@yonnierenton61775 ай бұрын
  • You Probably Shouldn't Use React.

    @orderandchaos_at_work@orderandchaos_at_work5 ай бұрын
KZhead