New React useEffectEvent Hook Crash Course

Поділитися
Вставка
  • Опубліковано 30 січ 2025

КОМЕНТАРІ • 193

  • @andTutin
    @andTutin Рік тому +147

    coming next: useStateEvent, useRefEffect, useEffectEffect

    • @Almighty_Flat_Earth
      @Almighty_Flat_Earth Рік тому +13

      React js is a blasphemy for JavaScript community. React nonsense must be banned across world plane. This f library makes web development unnecessarily complicated.
      Angular is far better than svelte and react nonsense., because it leverages rxjs subscription, angular service make communication between sibling components much easier, developers know what exactly is happening.
      Svelte and react have confusing code. Developer experience matters.

    • @andTutin
      @andTutin Рік тому +18

      @@Almighty_Flat_Earth wow you mad haha.react is not that complicated. but some aspects. yeah. mess. i used nest js a lot recently. people say its like angular for backend. liked it a lot. gonna learn angular one day

    • @Adiu72
      @Adiu72 Рік тому

      @@Almighty_Flat_EarthI was a backend dev my whole carier but last 2 years I had to use React every day with typescript and honestly I love it. It is very fast in writing and quite simple to me. As a backend dev who thought that will never do a front end I can recommend it to anyone :P

    • @danko95bgd
      @danko95bgd Рік тому

      @@andTutin it's not about being complicated or easy. It's just a suboptimal tool.
      Frankly it's dogshit

    • @golfgrab9481
      @golfgrab9481 Рік тому

      @@Almighty_Flat_Earth is Angular self closing tag feature celebrate end?

  • @Stoney_Eagle
    @Stoney_Eagle Рік тому +30

    One of my main frustrations in react is getting solved, I am a fan!

  • @exoticcoder5365
    @exoticcoder5365 Рік тому +1

    I really hate the haters in the comment section saying the channel should simplify the concept but the content is so hard, I think Kyle did a great job explaining, I thank him for teaching us more complicated stuff

    • @rifwann
      @rifwann Рік тому +1

      I believe what people hate is the hook itself not kyle.

  • @hugodsa89
    @hugodsa89 Рік тому +6

    This will make useEffect so much more usable. Thanks for covering this Kyle.

  • @Smoljames
    @Smoljames Рік тому +1

    Can feel my brain growing 🧠

  • @giladkay3761
    @giladkay3761 Рік тому +9

    2:21, can't I just ignore the warning? What can happen

    • @firestormmultigaming8697
      @firestormmultigaming8697 Рік тому

      clearly was thinking the same, I'll just wait for an update on your comment

    • @xrr-1
      @xrr-1 Рік тому +4

      If you ignore the warning, the onConnected function that the useEffect uses will be stale and cause bugs. For example, the effect could use onConnected function that is unaware of the latest loggingOptions when the loggingOptions prop changes.

    • @firestormmultigaming8697
      @firestormmultigaming8697 Рік тому

      @@xrr-1 thank you, made me understand a bug in my side project, bless you

    • @leopolon
      @leopolon Рік тому

      This logic get much more fragile against future changes.

    • @usmanabdurehman97
      @usmanabdurehman97 Рік тому +2

      @@xrr-1 isnt this happening in this case as well? useEffect would run only when url changes. When url changes we would connect to the room using the url and the onConnected would be called. even if logging options change, the useEffect wont run again and the onConnected function wont be called with the updated loggingOptions.

  • @jhirn2957
    @jhirn2957 11 місяців тому +1

    Is there a way to use the without experimental. I have package conflict otherwise I would upgrade but I just want this specific hook. Are there any 3rd party libs that provide something similar. I'm doing a lot of 2d canvas stuff where granular control of Effects and Evnets would be really helpful.

  • @nightcoder5k
    @nightcoder5k Рік тому +1

    I have to say React is a big hack. It could be simpler. Thanks for the awesome video, btw.

  • @lescobrandon2202
    @lescobrandon2202 Рік тому +1

    Yeea buddy, lightweight!

  • @Gabriel-iq6ug
    @Gabriel-iq6ug Рік тому +3

    I am not a native English speaker but listening to you is always very clear

  • @sushmitgaur8537
    @sushmitgaur8537 2 місяці тому

    3:40 why is that a problem? doesn't it make sense for onConnected function definition to update if loggingOptions change?

  • @vladgribennikov
    @vladgribennikov Рік тому +2

    Why we can not using onConnected function outside ChatRoom? This function takes arguments so we don't need put it into che ChatRoom component. Could you please clarify this case?

  • @evilLincoln
    @evilLincoln Рік тому

    When i faced that problem i just disabled linter rule for useEffect dependencies :) thanks for explaining the proper way

    • @erictremblay6867
      @erictremblay6867 Рік тому

      So you run your useEffect with outdated value?

    • @rifwann
      @rifwann Рік тому

      ​@@erictremblay6867i dont get what are you trying to say, or is it even possible..

    • @erictremblay6867
      @erictremblay6867 Рік тому

      @@rifwann Any value not added to the dependency array are not refresh inside a useEffect. If you want a value to be always up to date and not be in the dependency array you need to use a ref (useRef).

  • @channel6k
    @channel6k Рік тому +6

    Sir please please make a video on Cypress testing and react testing 🙏🙏

  • @guillaumenougier1197
    @guillaumenougier1197 Рік тому +4

    and for this issue what about simply use a ref ? if we store logginOptions into a ref and use the ref value in the function it should work right?

    • @abhinavreddyboddu6351
      @abhinavreddyboddu6351 Рік тому +1

      This is what chatgpt suggested me and i am happy they it worked.
      I had to do such stuff for my college assignment

    • @erictremblay6867
      @erictremblay6867 Рік тому

      Yes useRef to store the value and useEffect to update the ref. This is the workaround currently and this is what useEffectEvent does in the back.

  • @leopolon
    @leopolon Рік тому +5

    I didn't even know. this hook makes so much sense. I believe you could fix the problem you presented wrapping logging options in a useMemo and so on, BUT DAMN i JUST WANT TO RUN IT AFTER AN EVENT, LET ME DO IT, REACT. This is awesome. Loved it. Thanks

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому +1

      No, a useMemo would not work

    • @erictremblay6867
      @erictremblay6867 Рік тому

      I think you mean a useRef. useMemo would not help since you would still need to update your method. useRef is the method I use because my project is huge and updating to the new non fonctioning router is not an option.

  • @alasassi5889
    @alasassi5889 Рік тому

    can u make a video on how to stay productive I feel u are one of the productive people I know

  • @amjedbouhouch7993
    @amjedbouhouch7993 Рік тому +11

    I ran into those issues and I hate it so much. They are trying to solve those problems by making react more complex than it was.
    I always trying to avoid useEffect. And now they're adding more use use use and this is scares me.
    Imagine react without useEffect 🔥

    • @russtran
      @russtran Рік тому

      React internal team is working on this. You just might not heard about it because it's not promoted or mentioned by the youtubers, influencers, etc. ua-cam.com/video/lGEMwh32soc/v-deo.html

    • @russtran
      @russtran Рік тому +2

      Also I agree, I hate dependencies so damn much. If React can get rid of them, it would be superb.

    • @ngochunglongnguyen4523
      @ngochunglongnguyen4523 Рік тому +1

      react class component makes more sense to me. Although It would be more verbose when the component has many props and states.

  • @koksikskkj7937
    @koksikskkj7937 Рік тому

    Why can't we use value in useEffect which out putting them in array of dependencies? Why does it requires? 2:45

  • @justice8703
    @justice8703 Рік тому +3

    How about we eslint-disable-next-line?

    • @yd8874
      @yd8874 Рік тому +1

      Because the useEffect hook will use the old version of options. You'd need to wrap them with a useRef hook.
      I believe that's is how it's done under the hood.

  • @lucadalmasso3122
    @lucadalmasso3122 Рік тому

    is there a repository for this? I can't get it to work, the linter is still showing the missing dependency

  • @sebabratakundu
    @sebabratakundu Рік тому +14

    What if I simply don't pass the unnecessary dep in useEffect ? What problem will it create other than showing a warning?

    • @daydreamer9469
      @daydreamer9469 Рік тому

      In some codebases like where I’m working at, if the amount of warnings exceed a certain number, I can’t push my changes.

    • @sebabratakundu
      @sebabratakundu Рік тому

      @@daydreamer9469 that's interesting to know. But the boundary is created by your org. That is not related to react.
      BTW, thanks for your response ☺️

    • @EnkeyMC
      @EnkeyMC Рік тому +1

      You will start to ignore these warnings all together and you will forget to add some dependencies that may not be critical, but not including them will introduce bugs, that may be hard to find. We used to disable the warnings if we did not want to include something in the deps on our project, but later we found that it itroduced some bugs (even though we disabled it very rarely). So from that point we promoted it from warning to error, and forbid to disable this eslint rule and we did not encounter any similar bugs ever since. So I very much recommend to use this eslint rule and even have it as error not just warning.

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому +1

      There is a big misconception that new frontend developers tend to have because they just quickly moved to these frameworks instead of learning the basics first. If you only provide the url in the dependency array, the onConnected function will always be called with the initial logging options when the effect was created. In this case, the benefit of the new hook is that it will keep the logging options up to date, without having to recreate the whole effect

    • @sebabratakundu
      @sebabratakundu Рік тому

      @@ajfalo-fi3721 I don't get it what do you mean by "new frontend developer". If it's for me. Let me ask you a question, do you know me?
      Do not pass judgement without knowing the person.
      BTW thanks for your response.

  • @Dipenparmar12
    @Dipenparmar12 Рік тому

    Nice, 👍 simplified example

  • @eliebismuth412
    @eliebismuth412 Рік тому

    Please, someone can explain me why react warns about the onConnected function only after Kyle added the loggingOptions parameters ?
    At the beginning of the vidéo on 1:30, why we dont see a warning telling that useEffect has a missing dependency, the onConnected function ?

    • @theodorealenas3171
      @theodorealenas3171 Рік тому +1

      If I understand, it's because onConneced only changes when url changes. So it's not an extra dependency. When url changes, then they've both changed, and that's it. You don't track onConnected separately.
      I don't know JavaScript by the way but knowing low level programming does help me understand. Not that I understand much though. My head hurts when I try to understand JavaScript.
      Apparently each variable has 2 functions that are implied, some set and get, as well as an array for each. An array of functions for each. When set is called, it sets the value, and calls all the functions of the first array. When get is called, it calls all the functions of the other array and it returns the value. That's probably how it works. So what useEffect does, when it's called, is, it takes its second argument which is a lost of variables and for each it tells it to add it's self on the end of the setter array, something like that.

    • @erictremblay6867
      @erictremblay6867 Рік тому

      Because the useEffect is updated only when the url change. So essentially if you would change loggingOptions and then change the url. The onConnect method inside the useEffect would be the old one with the old loggingOptions.

  • @whitebelt4148
    @whitebelt4148 Рік тому

    nice, great explanations!

  • @Zagoorland
    @Zagoorland Рік тому

    I bet this example would work out of the box in solid js without the need of importing weird hooks

  • @deepmane5845
    @deepmane5845 Рік тому

    Hey Dev I want video on useMemo and UseCallback I can not figure it out when to use and which one use

  • @517nickyj
    @517nickyj Рік тому +1

    So this is another hook that wraps a function that can be called in a useEffect. But the function this hook wraps doesn't need to be a dependency of the useEffect, is that the jist? like is that the main difference between this and useCallback and useMemo?

    • @erictremblay6867
      @erictremblay6867 Рік тому +1

      You still need to listen to useMemo value or they could be outdated. The current solution is a useRef that is updated with a useEffect.

  • @rodrigolaporte274
    @rodrigolaporte274 Рік тому

    This is VERY interesting!

  • @lemon_maho
    @lemon_maho Рік тому

    oh mannnn finally!!!!!!

  • @GachiTscho
    @GachiTscho Рік тому +7

    My first instinct was also to ignore the warning. What I think didn't get enough stress in the video is that the onConnected function is an async one (not all callback are async), and when it gets called asynchronously at a later time, it is using the closure when url was last updated. this closure includes the onConnected definition and the logginOptions at that time.
    So between the time when url was last updated and the time when the async callback gets called with the earlier closure, loginOptions may have changed already which means the async callback captured an outdated closure.
    But I think the common unofficial way is to use a ref to point to the onConnected function and let async callback call the ref (what alibaba/hooks calls useLatest? great hook lib with not so good docs btw). Sincerely I hope this hook won't make it out of experimental, the solution seems worse than the problem it tries to solve.

    • @joleDEV
      @joleDEV Рік тому

      Doesn't the prop change automatically trigger an rerender? So if logging options changes the component get rerendered.

    • @fabienbroquard7690
      @fabienbroquard7690 Рік тому +1

      Haha, I was thinking the same..
      It seems like a pointless hook adding just sugar coating for people who can't figure out the many ways of doing that that already exist.. If I'm right, this behaviour can for example be achieved using a useEffect with dependency loggingOptions, which sets a ref of logginOptions, then set onConnected in a useRef too (or outside the component, taking in the ref as param..).
      outside the component (since logConnection is also outside, it makes the most sense..)
      const onConnected = (url, loggingOptionsRef) => {
      logConnection(...url, loggingOptionsRef.current...);
      }
      ...
      inside the component...
      const loggingOptionsRef = useRef(loggingOptions);
      useEffect(() => { loggingOptionsRef.current = loggingOptions; }, [loggingOptions]);
      useEffect(() => {
      ...
      room.onConnected(() => {
      onConnected(url, loggingOptionsRef).
      .. there is no need for 'onConnected' anymore, it could just be logConnection(...url, loggingOptionsRef..) directly here, if logConnection is changed to access current..
      ...
      ? Shouldn't that work eaqually well?

    • @rapzid3536
      @rapzid3536 Рік тому

      @@fabienbroquard7690 Just like useImperativeHandle which is just a shortcut to what you can do yourself in a useEffect or custom hook by assigning ref.current props.
      I'm not convinced this hook does anything other than shut up the linter. Nobody can explain what it actually does; will have to dig into the source code.

    • @rifwann
      @rifwann Рік тому

      I do hate this useEffectEvent, it doesnt looks practical. surely there are ways to tackle it without re-inventing hook just for 1 use case. (Although i dont know how its going to be)

  • @theisoj
    @theisoj Рік тому +2

    Thanks Kyle for this crash course!

  • @VladDubovyi
    @VladDubovyi Рік тому

    When should we expect it to be officially out?

  • @kaifriebe5547
    @kaifriebe5547 Рік тому

    Hi Kyle,
    I wish you health, strength and happiness!
    I hope, that you will always go ahead!
    Sincerely Kai

  • @ROY4144
    @ROY4144 Рік тому +3

    Isn't it is a solution to just leave the error as it is?

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому +1

      No, this is a big misconception that new frontend developers tend to have because they just quickly moved to these frameworks instead of learning the basics first. If you only provide the url in the dependency array, the onConnected function will always be called with the initial logging options when the effect was created. In this case, the benefit of the new hook is that it will keep the logging options up to date, without having to recreate the whole effect

  • @xcrxwadda8287
    @xcrxwadda8287 Рік тому +1

    That's why I love this channel always up to date

  • @ksidharth1994
    @ksidharth1994 6 місяців тому

    Either just use signals or use class based component

  • @dellavita3463
    @dellavita3463 Рік тому

    How to implement right now without experiment feature ?

  • @AutisticThinker
    @AutisticThinker Рік тому

    0:00 - word typo "useEventEffect' instead of 'useEffectEvent'.

  • @besuccessfull1891
    @besuccessfull1891 Рік тому

    I am beginner , but can't we use , useRef to store options and then use useLayoutEffect to update ref current value and then return result ?

    • @erictremblay6867
      @erictremblay6867 Рік тому

      Don't need useLayoutEffect, useEffect to update the ref is ok no need to wait for the dom to render.

  • @inqvisitor3722
    @inqvisitor3722 Рік тому

    can i use ref for callback in this case?

    • @erictremblay6867
      @erictremblay6867 Рік тому

      Yes using useRef and a useEffect to update the ref is the current work around and essentially what the new hook does in the back.

  • @rishiraj2548
    @rishiraj2548 Рік тому

    Thanks

  • @pranavbhat29
    @pranavbhat29 Рік тому

    So is it the case that useEffectEvent is just a specialised useRef only for functions?

    • @mechaD
      @mechaD Рік тому

      I was thinking the same. I assume, right now I would use a useRef with a function for such a use case. Might be interesting to check how useEffectEvent is implemented. 🤔

  • @aname3351
    @aname3351 Рік тому +1

    Nice. I recently was working on creating own useFetch implementation and I run in to the problems of passing url and options object. Read through react beta documention and found this hook.

  • @bafian
    @bafian Рік тому +1

    better switch to Vue or Svelte guys

  • @nyxdesign3191
    @nyxdesign3191 Рік тому

    Hey, it would be great if you create a tt about netlify website (creating the whole website)
    Thanks

  • @jp_vids9631
    @jp_vids9631 Рік тому

    Can you please make a video about Object Relational Mapping and Model view controller.

  • @oyerindedaniel7977
    @oyerindedaniel7977 9 місяців тому

    something wey i go disable. dey play

  • @sanctuary_inheritor
    @sanctuary_inheritor Рік тому +3

    So... Basically a ref?

  • @Locuester
    @Locuester Рік тому +1

    Good explanation.
    Why no semi-colons? Pro Tip: I know you don't _need_ them, but it makes the code easier to read. Similar to how you're using curly braces even when they aren't needed on one-liners.

  • @chemedev
    @chemedev Рік тому +5

    Looks like if you know what you're doing is easier to disable the eslint dependencies rule just for that line and problem solved...

    • @erictremblay6867
      @erictremblay6867 Рік тому

      How do you know that you have an up to date value?

    • @chemedev
      @chemedev Рік тому

      @@erictremblay6867 if the effect depends on a prop the value will always be updated since the whole component and effects run when it changes.

  • @KevinVandyTech
    @KevinVandyTech Рік тому +5

    Last I heard, they were planning on cancelling the planned release of this hook.

  • @eleah2665
    @eleah2665 Рік тому

    Hi Kyle, great as usual. I'm going to find a way to use the word "niche" today. It's a fine word.

  • @zivtamary
    @zivtamary Рік тому +4

    pure React is starting to look messy compared to Next/Solid/other options =/

  • @TodorImreorov
    @TodorImreorov Рік тому

    why not just have onConnected as normal function? I am missing the benefit of this new hook vs not wrapping it with a hook at all

    • @erictremblay6867
      @erictremblay6867 Рік тому

      He explained that. The method would not be up to date in the useEffect. Essentially calling an older version of the method with older value.

  • @code.cracking
    @code.cracking Рік тому

    Great

  • @richardbrennan7595
    @richardbrennan7595 3 місяці тому

    need app that will stop two trains from colliding. useEffectEvent would work

  • @SwapnilSoni
    @SwapnilSoni Рік тому +1

    better shift on svelte

  • @mnikk1
    @mnikk1 Рік тому

    Just turn on eslint for that line 😅

  • @sidisting1381
    @sidisting1381 Рік тому

    What if you just ignore that first warning in the first place. That's my way of solving those problems 😅😅

  • @kinstar
    @kinstar Рік тому +14

    It makes sense but we dont really need to add dependencies we dont need even though react complains about it. Could just add more complexity for nothing

    • @Septrba
      @Septrba Рік тому

      Exactly

    • @liviuganea4108
      @liviuganea4108 Рік тому +1

      .... you add dependencies to let react know when to enter the useEffect. [] - enter the first time, just after render .... , [x] - enter after X has changed, [x, y] - enter after X OR Y has changed

    • @erictremblay6867
      @erictremblay6867 Рік тому

      If you don't add the dependency the value will not be up to date.

    • @Septrba
      @Septrba Рік тому

      @@erictremblay6867 it depends on what do you need to be up to date with

    • @Septrba
      @Septrba Рік тому

      @@erictremblay6867 I mean sometimes you know that certain values will be always the same, and maybe they will change just because they are functions (will change the reference) so in this case just don't add them to the dependency array

  • @syedalimehdi-english
    @syedalimehdi-english Рік тому +1

    // @ts-ignore 😂😂😂😂

  • @Angeal98
    @Angeal98 Рік тому +7

    Just disable eslint rule about hook dependancy array. It's a seriously naive rule, sometimes you don't want everything in the dependancy array.

    • @arjundureja
      @arjundureja Рік тому +3

      That's exactly how you get bugs in your code

    • @usmanabdurehman97
      @usmanabdurehman97 Рік тому

      @@arjundureja Imo you should only follow it for useCallback and useMemo. For useEffect add only those which match your scenario and ignore warning

    • @thalibmuhammad9519
      @thalibmuhammad9519 Рік тому +3

      whats the potential bug, curious...

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому +1

      This is a big misconception that new frontend developers tend to have because they just quickly moved to these frameworks instead of learning the basics first. If you only provide the url in the dependency array, the onConnected function will always be called with the initial logging options when the effect was created. In this case, the benefit of the new hook is that it will keep the logging options up to date, without having to recreate the whole effect

    • @usmanabdurehman97
      @usmanabdurehman97 Рік тому +1

      @@ajfalo-fi3721 Sorry but you are wrong. I literally tested this example kyle has by keeping only url as the useEffect dependency and it always gets the updated loggingOptions whenever the url changes

  • @theodorealenas3171
    @theodorealenas3171 Рік тому

    It's hard to understand how JavaScript works behind the scenes. I really do wonder what knobs useEffectEvent turns to the lambda that you pass into it. It turns the variables of the lambda into pointers? It's too late to do that, they've been passed by value now. I really want to know. JavaScript scares me a little.

  • @truongthien9456
    @truongthien9456 Рік тому

    Why u don't just wrap it in useRef hook

  • @coder2917
    @coder2917 Рік тому

    Great explanation, thanks, Kyle for sharing this.

  • @lucio9601
    @lucio9601 2 місяці тому

    Fucking amazing bro

  • @usmanabdurehman97
    @usmanabdurehman97 Рік тому +11

    This doesnt make any sense. If you want to trigger your useEffect when certain dependencies change then ignore the eslint warning and include only the ones you want as dependencies. This hook just removes the eslint warning. The hooks warning should only be followed for useMemo and useCallback strictly. For useEffect we should use it per usecase

    • @migueljara9399
      @migueljara9399 Рік тому +6

      Exactly my thoughts, this just adds unnecessary complexity to your code

    • @andTutin
      @andTutin Рік тому +3

      there is a chapter in new react docs about removing unnesessary dependencies

    • @ahmad1734
      @ahmad1734 Рік тому +1

      No what if u want to access the latest value of another value which is loggingOptions in Kyle's example, using the new hook will grants you latest value

    • @dylan-j-gerrits
      @dylan-j-gerrits Рік тому +5

      Exactly, creating a hook to remove ESLint warnings is kind of useless...

    • @usmanabdurehman97
      @usmanabdurehman97 Рік тому +1

      @@ahmad1734 it would give you the latest value in the case when I just put just the url in the dependency as well.

  • @avinashvishwakarma1681
    @avinashvishwakarma1681 Рік тому +1

    In starting he said useEventEffect hook

  • @bibahbibah5108
    @bibahbibah5108 Рік тому

    it's not making sense, the code is more complicated, u have just to not add function in the params array.
    if i should tel why

  • @programmer545
    @programmer545 Рік тому

    Please bring some MERN stack real time project

  • @thalibmuhammad9519
    @thalibmuhammad9519 Рік тому +1

    useless hook, just remove the dependency and the eslint warning is enough
    or...you might be missing the actual point of usage from this hook?

  • @deepaksebak1594
    @deepaksebak1594 Рік тому

    can you share your pc wallpaper

  • @fredflix7945
    @fredflix7945 Рік тому

    In Next.js, if you try to use the useRouter hook inside a useEffect (router.push), it can lead to an infinite loop. This is because calling useRouter updates the router, which triggers the useEffect to re-run. Is the useEffectEvent hook a possible solution to this issue?

  • @TannerBarcelos
    @TannerBarcelos Рік тому

    React is getting crazy with all these hooks now.
    Love React, but it’s getting out of hand. These other frameworks are doing so much more for us without all this bloat.

  • @echobucket
    @echobucket Рік тому +2

    Just more band-aids on bad designs from the React Team. Yay.

  • @nohox9444
    @nohox9444 Рік тому +2

    Force me to put anything in the dep array? I decide what I put in my dep array and not some weird lint rule. To be an experts means that u know what u are doing and not to depend on your linter…

  • @MaulikParmar210
    @MaulikParmar210 Рік тому +5

    Just put function outside the main module, and you should be able to use it as normal JS function just like any other functions declared below.
    You don't always need it to be in the same context as the main component. That's how you do it in a more clean way and simply pass the values, or even better delcare separate services module and import it....

    • @koksikskkj7937
      @koksikskkj7937 Рік тому +1

      Oh yeah that's right. Remeber that hooks allows us to manipulate JSX and data which are reactive. Often hooks trigger to run component again, so we don't want to re run the complex functions which are not dependend by value which changes. We can just move the functions outsiede the component and run it inside

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому

      No, in this case it cannot be declared outside because it uses the logging options

    • @MaulikParmar210
      @MaulikParmar210 Рік тому

      ​@AJFA Lo-fi That's where you memoize function so it stays static till options do change. At the point when options do change, your function reference also gets updated once.
      Problem is react in functional approach slams everything at one place making it hard to grasp concept of dependency and callbacks that works with it, even experienced people get lost in control flow and mapping whuch function gets called in which iteration.
      P.S. you will always need atleast one function telling react about dependency, if not expect react to call it every render sinxe react calls entire component function and then effects do take place depending on those dependencies

  • @whynotdean8966
    @whynotdean8966 Рік тому

    Or you could just "eslint-disable-next-line".

  • @ricko13
    @ricko13 Рік тому

    better switch to Solidjs or Svelte and forget about useEffects and sh1t

  • @SoreBrain
    @SoreBrain Рік тому +1

    React is a mess. I don't understand why it took so long for this to be added.

  • @graa999
    @graa999 Рік тому +3

    Or we just can do not put extra argumets into dependency array. And add disable eslint for this shitty line

  •  Рік тому

    useRef

  • @sergheimitroshin9467
    @sergheimitroshin9467 Рік тому

    Interesting what kind of crutch will require this new hook. Because it's already a crutch for useEffect.
    React nowadays is a crap.
    React's docs tells you, like - this is "useEffect" and you can put in deps array any variable that you want to watch for changes to run your useEffect.
    But, they don't put accent that you are not allowed to escape from deps array variables used inside useEffect.
    Otherwise, you'll have tones of hidden bugs.
    Isn't it confusing ?
    And at the end, you don't watch for changes variables that you want to watch, you are just obligated to fill the deps array with all the variables used inside useEffect.
    And of course you will spend a lot of time after, to debug this crap and make it called only when you need by covering your functionality in "if" statement, which often becomes huge.
    So not you are controlling the useEffect,
    useEffect is controlling you.
    Such a mess.

  • @trappedcat3615
    @trappedcat3615 Рік тому +1

    Anyone else overwhelmed with React this and React that, everywhere? There are a lot of other powerful JS projects. I wish React would just go away at this point.

    • @theodorealenas3171
      @theodorealenas3171 Рік тому +1

      It's not THAT bad. Mixing projects together is my worst nightmare.

  • @zlackbiro
    @zlackbiro Рік тому

    I am so tired of React's experimental things! Like infinite non-stable things appeared last 6 months. They solved none of them!

  • @itsadira007
    @itsadira007 Рік тому

    Please make video on redux-saga and reapex

  • @kashnigahbaruda
    @kashnigahbaruda Рік тому

    This is why React sux. It's been this long and they still haven't solved this.

  • @Senshiii99
    @Senshiii99 Рік тому

    React looks like it is in crisis

  • @deepudagar3563
    @deepudagar3563 5 місяців тому

    bro your head needs gimble

  • @SithLordBishop
    @SithLordBishop Рік тому

    useEffect made me hate react

  • @changNoi1337
    @changNoi1337 Рік тому

    Your face is bigger now? it's slightly confusing.

  • @siya.abc123
    @siya.abc123 Рік тому

    React is hacky, I'm going back to Vue. They seem to have Nuxt 3 sorted now. Back to react if Vue breaks again

  • @Almighty_Flat_Earth
    @Almighty_Flat_Earth Рік тому

    React js is a blasphemy for JavaScript community. React nonsense must be banned across world plane. This f library makes web development unnecessarily complicated.
    Angular is far better than svelte and react nonsense., because it leverages rxjs subscription, angular service make communication between sibling components much easier, developers know what exactly is happening.
    Svelte and react have confusing code. Developer experience matters.

    • @yd8874
      @yd8874 Рік тому

      With its ugly html DSL? C'mon man.

  • @deepcrashcourse
    @deepcrashcourse Рік тому +1

    Thanks