You're Doing React Hooks Wrong, Probably

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 2024

ความคิดเห็น • 217

  • @ArunShankartheRealOne
    @ArunShankartheRealOne 3 ปีที่แล้ว +36

    I remember writing a filter table function with hooks , and suddenly something just clicked.

  • @krtirtho
    @krtirtho 3 ปีที่แล้ว +37

    I really appreciate that you're using Typescript primarily in tutorials
    Except Ben Awad & you I never saw anyone using Typescript primarily in tutorials

    • @lutfiikbalmajid3128
      @lutfiikbalmajid3128 2 ปีที่แล้ว +1

      you may seen often if watching Angular tutorial :D

  • @Deliverant
    @Deliverant 3 ปีที่แล้ว +72

    I love you Jack and what you're doing for the community, you're my inspiration

    • @noccer
      @noccer 3 ปีที่แล้ว +3

      Same. A terrific teacher ☘️

    • @andresserron8596
      @andresserron8596 3 ปีที่แล้ว +1

      indeed he rise the bar

    • @alexcooper4845
      @alexcooper4845 2 ปีที่แล้ว

      100%

  • @igrb
    @igrb 3 ปีที่แล้ว +17

    All the explanations are so tight, seeing the dependency diagram helped a lot! You're the only person I've seen on youtube that can explain things so well in a practical way while showing the technical aspect of it. Thank you so much for the content

  • @diyaagubarah3328
    @diyaagubarah3328 2 ปีที่แล้ว +1

    nice as usual we are happy we have you as our senior

  • @matthew1106
    @matthew1106 2 ปีที่แล้ว +8

    It's so worth it to take the effort and time to watch and review ALL of Jack's videos. It really shows how much time and thought he puts into giving his knowledge to the community for FREE. Thank you for all you do Jack!

  • @tabliqatchi6696
    @tabliqatchi6696 ปีที่แล้ว

    Without exaggeration you are one of the most interesting people I've ever seen on the Internet..., the way you teach makes me cry lol! I wish our world had MANY teachers like you 👌

  • @basharkhadra2929
    @basharkhadra2929 2 ปีที่แล้ว +4

    Your videos is on another level comparing to other TH-cam channels. Thanks for the efforts

  • @dc33333
    @dc33333 ปีที่แล้ว +1

    wow you are good. Always a couple steps over the average explanation.

  • @esmaeilmirzaee
    @esmaeilmirzaee 3 ปีที่แล้ว +2

    No matter how much experience one has, every time you would learn something new. Awesome explanation. Thank you so much.

  • @rubenverster250
    @rubenverster250 2 ปีที่แล้ว +2

    Hey man. I love your channel so much!
    Like it is so hard finding a channel that dives more into the complex topics...
    You're absolutely stellar for more advanced info, especially since I'm now at Intermediate level :D
    Big

  • @ayoubbani6762
    @ayoubbani6762 3 ปีที่แล้ว +1

    Happy birthday Jack!

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      Thanks!

  • @AbdelhameedG
    @AbdelhameedG 3 ปีที่แล้ว +6

    Thanks you Jack , that was very informative, hope to see you diving more into the advanced topics in React.

  • @johannsebastianbach3411
    @johannsebastianbach3411 3 ปีที่แล้ว +1

    Mr Herrington, I know you probably get this all the time, but you rock!! This was really elegant!!

  • @JavierPortillo1
    @JavierPortillo1 2 ปีที่แล้ว

    I come from a vue background and it was just so clear when you compared useMemo to computed values. Thank you!

  • @andresserron8596
    @andresserron8596 3 ปีที่แล้ว +1

    Amazing display,
    The touch of proficiency is the diagram at the end of the video, no bs as usual!

  • @eXmatic
    @eXmatic ปีที่แล้ว

    Thank you Jack for all of your high quality, in depth content. I'm so glad that i stumbled across your channel. You are explaining the concepts of React in a more detailed manner, which are often necessary when someone really wants to get a job as a React developer. Most React / programming channels on youtube only show the surface of some concepts. You explain more in depth, and in a way that it is really easy to understand. Your channel is truly underrated, I hope more people will find your channel.

  • @jr-hp7er
    @jr-hp7er 3 ปีที่แล้ว +1

    Now, it feels, i was always using the hooks in a very much wrong way. Thanks to Uncle Jack for teaching us the right way:) Loved it, awesome

  • @liltripple_reid8917
    @liltripple_reid8917 3 ปีที่แล้ว +6

    If you take a look at his code you'll see that he truly is a senior dev

  • @TheL0rdOfTheStrings
    @TheL0rdOfTheStrings 3 ปีที่แล้ว +1

    Man your explanations are so clear. Well done. Wish I had this kind of tuition when I was starting learning JS and React.

  • @nubl37
    @nubl37 3 ปีที่แล้ว +1

    man the border radius on your webcam is given me old school CSS vibes
    amazing content and presentation

  • @guilhermeprezzi7783
    @guilhermeprezzi7783 3 ปีที่แล้ว +1

    Where is the love reaction button yt?? I need it because like this video isnt enough! Awesome work Jack!
    I just missed you commenting that in some scenarios it's interesting to separate each atomic intention (use-cases) of the user into separate hooks (and how useful this can be for large systems in terms of testing and reuse) eg useGetPokemons(filter ), useCalcPokemonMinPower(pokemons), useCalcPokemonMaxPower(pokemons), useCountPokemonWithPower(pokemons, threshold) and so on

  • @kleberluisaraujomottajunio4218
    @kleberluisaraujomottajunio4218 2 ปีที่แล้ว +1

    Thanks!

  • @SaifAlFalah
    @SaifAlFalah 3 ปีที่แล้ว +3

    Thanks for the great video Jack! Your content is gold!

  • @ghassanclassic7689
    @ghassanclassic7689 2 ปีที่แล้ว +1

    You’re legendary. I watched almost all your videos. Thank you very much for the amazing content, keep it up 🥇🏆

  • @cassioscabral
    @cassioscabral 2 ปีที่แล้ว +1

    Coming from Vue, I was watching and thinking "this is just like a computed property" and then you said that was just like it. I honestly was "afraid" of using useMemo when even the docs say to not use it often. But in your example, it does not only make sense, but I agree that having that list of dependencies makes clear that to "compute" this value depends on those other values.

  • @tiennsloit
    @tiennsloit ปีที่แล้ว +1

    Love you, I think I am gonna watch all your react videos 😅

  • @onkelZweiback
    @onkelZweiback 3 ปีที่แล้ว

    I just had to subscribe after this Video. Awesome content keep it up!

    • @jherr
      @jherr  3 ปีที่แล้ว

      Thanks!

  • @sasatatar
    @sasatatar 2 ปีที่แล้ว +1

    Just a small correction in the description: It's Kent C. Dodds, not Dobbs. Other than that awesome content, I learned a ton, from both of you! :)

    • @jherr
      @jherr  2 ปีที่แล้ว

      Whoops, my bad.

  • @IctioPar
    @IctioPar 3 ปีที่แล้ว +1

    So glad to have found this channel, great content!

  • @JustinProfaizer
    @JustinProfaizer 2 ปีที่แล้ว +1

    I have never had anyone explain all of the React intricacies so well.

  • @kumarnitesh60
    @kumarnitesh60 3 ปีที่แล้ว +2

    Another great tutorial.
    Your video quality has improved a lot, if possible can you do a video on recording or creating tutorials, and the setup that you are using currently.

    • @jherr
      @jherr  3 ปีที่แล้ว

      Thanks. I appreciate that. That's really cool that you think it's good enough to do a video on. I'll definitely think about it.

  • @sidds5039
    @sidds5039 2 ปีที่แล้ว +2

    Ah that comparison with Vue's 'computed' mechanism really cleared up a lot for me - thanks!

  • @MmmMmmGood17
    @MmmMmmGood17 3 ปีที่แล้ว +2

    Thank you, this was very informative. It was a bit hard for me to follow because of having two components in one file. Just a recommendation to consider separating out the components into their own files. Thanks!

    • @jherr
      @jherr  3 ปีที่แล้ว +2

      Thanks for the feedback!

  • @wfoster92
    @wfoster92 2 ปีที่แล้ว +1

    This is amazing content! Your examples are top notch

  • @Larry-lv7dz
    @Larry-lv7dz 2 ปีที่แล้ว +1

    Thanks Jack! Awesome content as always

  • @admxxi
    @admxxi 3 ปีที่แล้ว +1

    Thanks for the great content! Btw: what keyboard are u using?

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      A Varmilo VA87M my daughter got me for my birthday.

  • @fernard8985
    @fernard8985 3 ปีที่แล้ว +2

    Great content, thanks. It rather reinforced my feeling that I use hooks correctly than showed me something I didn't know, but still a good watch. Btw, why haven't you simply computed min and max within a single useMemo call, returning an object rather than a integer twice?

    • @jherr
      @jherr  3 ปีที่แล้ว

      Probably could have, yeah.

  • @jofla
    @jofla 3 ปีที่แล้ว +6

    Where are you from? That background in the beginning looks beautiful.
    Thanks for this video

    • @jherr
      @jherr  3 ปีที่แล้ว +3

      Oregon. Although this is Lacamas Park in Camas, WA.

  • @JamesQQuick
    @JamesQQuick 2 ปีที่แล้ว +1

    Really good stuff!

  • @76Freeman
    @76Freeman 3 ปีที่แล้ว +1

    Thank you very much Jack for this very informative and clear video.

  • @mudscuffer
    @mudscuffer 2 ปีที่แล้ว +2

    useMemo and useCallback definitely have their place, but writing code like this you start feeling like you need them everywhere. It's a lot of boilerplate. It's can be worth taking a step back before you reach for them.
    1. You could have achieved the same effect by instead separating the threshold input and count into a child component.
    2. You get no value from memoizing onChange listeners if you are passing them straight to inputs anyway.

  • @lilibayo
    @lilibayo 2 ปีที่แล้ว +1

    Fantastic video as usual. Thanks Jack!
    Lil question: Why did you end up wrapping onSetThreshold w/ useCallback? Looks like it is not being passed into a memoed child component, It also does not look like an expensive function.
    Thanks

    • @jherr
      @jherr  2 ปีที่แล้ว +1

      I probably didn't have to. When it comes to useCallback expensive doesn't matter. That's just about useMemo and it's one of two reasons to use useMemo; maintaining referential identities and, as you point out, expensive synchronous computes.

    • @lilibayo
      @lilibayo 2 ปีที่แล้ว

      @@jherr Got it! Thank you so much for the clear explanation.

  • @dellryuzi
    @dellryuzi 3 ปีที่แล้ว +2

    sorry jack what's the reason you usememo in min max too? when it's enough on pokemonWithPower to memoized the table?

    • @jherr
      @jherr  3 ปีที่แล้ว

      They are derived values. So the component can get re-rendered as many times as we want, but the min/max won't get re-computed unless the underlying data changes.

    • @dellryuzi
      @dellryuzi 2 ปีที่แล้ว

      @@jherr i think useMemo should be used when we really wanna pass the value to other component? Since using useMemo uses memory and too many useMemo usage will eventually result a bad performance caused by first read-time to decide whether value will be memoized or not.
      I've seen a lot of apps using too many useMemo and instead resulting a slower app.
      or perhaps jack do u have any idea when it's the best time to stop useMemo? rather than memoized everything?

    • @jherr
      @jherr  2 ปีที่แล้ว

      @@dellryuzi I haven't seen useMemo slow down an app. Comparing two arrays of scalars is a quick operation, and nobody is suggesting an app with useEffects is slower, and the dependency logic is the same between useMemo, useEffect and useCallback. If you're calculating an object or an array you should use useMemo because those are references, and if you do pass them somewhere to another component, or use that reference in a dependency array, you'll want it to managed by useMemo. If you are creating a scalar from useMemo then it's really a question of how long the scalar takes to calculate. If it's a simple expression then you probably shouldn't use useMemo, if it's the result of some iteration or a reduce, then you should probably use useMemo, otherwise not.

  • @shokhbozabdullayev6260
    @shokhbozabdullayev6260 2 ปีที่แล้ว +1

    Thanks for the great extension for diagramms)

  • @simonedwards7101
    @simonedwards7101 2 ปีที่แล้ว +1

    Hi Jack, I've not seen this line of code used before "const [pokemon, setPokemon] = useState([]);". I mean, I understand and have used the useState part but specifically not the part in that position. Is that a Typescript thing?

    • @jherr
      @jherr  2 ปีที่แล้ว +2

      Yeah. That’s typescript. You have to define what will go into the array. If you start with an empty array there is no way for it to know what you will be putting into it and making sure you always put the right kind of stuff.

    • @simonedwards7101
      @simonedwards7101 2 ปีที่แล้ว +1

      @@jherr Thanks for confirming Jack. I've not used or read Typescript as yet. Trying to focus (reduce my learning curve) on learning JavaScript, React & Next.

    • @thomasstambaugh5181
      @thomasstambaugh5181 2 ปีที่แล้ว

      @@simonedwards7101 I'm in the same boat. After more than two years of pretty much full-time React and NodeJS coding, I'm still struggling with basic syntax and "shortcuts" (such as the gazillion varieties of expressing an arrow function). I fully intend to use Typescript when I feel more confident of my understanding of the underlying Javascript that it relies on.

  • @TurboBorsuk
    @TurboBorsuk 2 ปีที่แล้ว +2

    There should be a separate comment section for all the praise and appreciation ;)
    I was scrolling through in hope to find someone disagree with you on this one - simply out of interest in other points of view, not saying I'm not buying your arguments, but when there are 2 programmers there are 11 solutions (

    • @thomasstambaugh5181
      @thomasstambaugh5181 2 ปีที่แล้ว

      The legendary Bill Joy once told me that the fundamental flaw of the "management" panacea of adding new programmers to a team that is behind schedule is that the rate of new code generation per developer expands linearly while the rate of new idea generation per developer expands exponentially. Since overall team productivity is the ratio of the former to the latter, team productivity asymptotically approaches zero as developers are added.

  • @sandeepsoni7269
    @sandeepsoni7269 ปีที่แล้ว

    Hey Jack thanks for the video. Can you share which font and theme you're using in your vscode.
    Waiting for reply.

    • @jherr
      @jherr  ปีที่แล้ว

      It's always in the description of the video.

  • @carminetambascia6355
    @carminetambascia6355 2 ปีที่แล้ว +1

    Jack is the Lead Senior anyone wish to have. But anyone can have a bit watching his video

  • @sandeepgupta2476
    @sandeepgupta2476 2 ปีที่แล้ว +1

    Can I add pokemon.length as dependecy in useMemo instead of whole pkemon array?

    • @jherr
      @jherr  2 ปีที่แล้ว +1

      Sure, but... If you changed the pokemon array to a new reference BUT the length remained the same, then that dependency wouldn't fire.

    • @sandeepgupta2476
      @sandeepgupta2476 2 ปีที่แล้ว

      @@jherr indeed, you made a greate point.

  • @Jmfufghf
    @Jmfufghf ปีที่แล้ว

    Great tutorial. One question is now I've learned about making forms with useRef to prevent rerenders, I like how clean and simple the code is vs storing state in useState. What do you think?

    • @jherr
      @jherr  ปีที่แล้ว

      Uncontrolled inputs are fine. Preferred in a lot of situations. Forms managers like react-hook-form primarily use uncontrolled inputs.

  • @jujijiju6929
    @jujijiju6929 3 ปีที่แล้ว +3

    Hi Jack, interested to see if you have any thoughts on the new SolidJS library.

    • @jherr
      @jherr  3 ปีที่แล้ว +2

      I have much much much love for SolidJS. This video me gearing up to show how SolidJS gets reactive state very right.

    • @jujijiju6929
      @jujijiju6929 3 ปีที่แล้ว +1

      @@jherr Awesome, looking forward to it!. I've been looking at it's docs last weekend and it feels really well thought out.

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      @@jujijiju6929 Not only well thought out but blazingly fast. I wrote a search page for my BCC videos in it and it's insanely fast.

  • @AAquaticAApe
    @AAquaticAApe ปีที่แล้ว

    Great video Jack! Question - Is it ok to disable my linter when I want to have an empty useEffect dependency array? It will usually tell me I need to have something inside or remove it entirely.

    • @jherr
      @jherr  ปีที่แล้ว +1

      You should never ever have an empty dependency array. And no, you should not disable the linter, it is almost always correct.

    • @AAquaticAApe
      @AAquaticAApe ปีที่แล้ว

      @@jherr Thanks Jack!

  • @krimod
    @krimod 3 ปีที่แล้ว +1

    Great content, I'm really thankful for all the work you put in your tutorials !! stupid question, i m writing it mid vid, I m still wrapping my head around the useMemo hook etc and i ve been thinking, if it so necessary, why is it not the default for state ? Sorry for my english.

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      If you give me a time reference I'll give you my reasoning about useMemo.

  • @lkd982
    @lkd982 2 ปีที่แล้ว +1

    brilliant demonstration

  • @gregstarr9633
    @gregstarr9633 ปีที่แล้ว +1

    Most excellent video.. highly valuable.. thank u so much

  • @ThEldeRS
    @ThEldeRS 3 ปีที่แล้ว +1

    I adore the diagram! Is this an extension or an OOTB feature? Thanks for the explanation about hooks, it was enlightening!

    • @jherr
      @jherr  3 ปีที่แล้ว

      OOTB feature. It's always been there.

  • @mansamusa559
    @mansamusa559 3 ปีที่แล้ว +1

    I'm learning so much from you thanks alot!!

  • @PaulSebastianM
    @PaulSebastianM ปีที่แล้ว

    I think I was afraid to overuse the hooks like this before seeing this. So many articles say to not abuse useMemo because it leads to performance issues, but judging by your examples, it seems like the opposite is true. Basically cache everything, or wrap everything that changes.

  • @NEGI_JI09
    @NEGI_JI09 2 ปีที่แล้ว

    Congratulate me) I finally found what I was looking for

  • @aestheticallyamazing2003
    @aestheticallyamazing2003 3 ปีที่แล้ว +1

    What intellisense did you use around 3:54 I'm totally mind blown

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      That's Github Copilot.

  • @MrEnsiferum77
    @MrEnsiferum77 3 ปีที่แล้ว +2

    Dependency graph, actually is topological sort in data structure context, or something similar.

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      Fair. In this case I was looking for a term that captured the dependencies between the various pieces of state, derived state and effects.

  • @tarunsukhu2614
    @tarunsukhu2614 3 ปีที่แล้ว +1

    You are a champion Jack! , Thank you

  • @leonewu7171
    @leonewu7171 3 ปีที่แล้ว +1

    i wonder what that vscode autosuggestions extension is. in 3:58

    • @leonewu7171
      @leonewu7171 3 ปีที่แล้ว +1

      haha, I know it as i watching the video. copilot

    • @jherr
      @jherr  3 ปีที่แล้ว

      Yep, it's copilot. Expect a video on that fairly soon.

  • @NorweskiDrwal
    @NorweskiDrwal 3 ปีที่แล้ว +3

    14:45
    min max could have also been achieved with useCallback(type: 'min' | 'max') and Math[type](...) , reducing the code duplication a little, I think ;)
    unless this would memoize only the callback, not what it returns, in which case we'd have to use useMemo anyway, which would not be the optimisation we wanted
    welp, sometimes over-optimisation hurts the performance, when you don't know what you're doing, which proves the point of this video :D

  • @ferooref7614
    @ferooref7614 3 ปีที่แล้ว +1

    Why do you need to destructure the array in 14:03 ?

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      Math.min expects multiple arguments, like Math.min(10,20,30). If I do this Math.min([10,20,30]) then it just wants to min that one array. If I do this Math.min(...[10,20,30]) that turns into Math.min(10,20,30) and I get the min value.

  • @chenrvn
    @chenrvn 3 ปีที่แล้ว +2

    Hey, thanks for sharing :-)
    I am not sure when you have a dependency you can use the use effect with his dependency array also, so when you need to use useEffect and when use Memo?
    BTW I didn't really understand what use Callback give us here because you show it without any dependency.
    Can you give an example please :-)

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      useEffect is "watch these values". useMemo is "compute this value from these values". and useCallback is the same thing but applied to functions. For custom hooks I would always use useMemo and useCallback because I don't know how the data and functions I return from the custom hook will be used. For component code, useCallback is optional, but I still recommend it if you are sending the callback to another component so that it retains referential integrity.

    • @NorweskiDrwal
      @NorweskiDrwal 3 ปีที่แล้ว +1

      useCallback holds a function that needs to run when given dependency changes
      in this case, we wanted to fire it only with event.target and we didn't need useCallback's context to watch for updates from that dependent variable
      if we included "pokemon" variable somewhere in that "onSetSearch", it means we want useCallback to know about "pokemon" too
      i hope this makes sense ;)

    • @chenrvn
      @chenrvn 3 ปีที่แล้ว

      @@jherr I think the conclusion need to be: do you want to make react to be Reactive? You need to use: useEffect, use Memo and use Callback :-)

  • @mikecastor2047
    @mikecastor2047 2 ปีที่แล้ว +1

    What a fantastic resource!

  • @Knowwhentobluff
    @Knowwhentobluff 2 ปีที่แล้ว +1

    But isn’t use memo doing triple equals too? If I have two objects I’m comparing and I change something deep inside the object .. it isn’t going to trigger the useMemo

    • @jherr
      @jherr  2 ปีที่แล้ว

      That’s correct. If the reference doesn’t change then it won’t fire. But… you can depend on the deeply nested value.

    • @Knowwhentobluff
      @Knowwhentobluff 2 ปีที่แล้ว

      @@jherr I have a useMemo that I use that depends on react query data..I change the object property deep inside the project on a post call api call success response… but my useMemo doesn’t rerun for the new values.. maybe i have to go deeper in the object for my useMemo dependency array?

    • @jherr
      @jherr  2 ปีที่แล้ว +1

      @@Knowwhentobluff you should depend on the values you use in the memo, deeply nested or not.

    • @Knowwhentobluff
      @Knowwhentobluff 2 ปีที่แล้ว

      @@jherr even if useMemo is like “omg this is an unnecessary dependency”

  • @kunjuperath
    @kunjuperath 3 ปีที่แล้ว +1

    For search is there a reason why you chose to refetch the data and do a filter rather than just filter the array that you already have locally? I guess refetching guarantees the latest data (which wouldnt help in this case) but on an onChange that seems like too many fetches imo.
    Thanks for the awesome video! Cheers!

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      The example is more about how to manage control flow. But in reality, yeah, it's a small dataset and in this case fetch is just going to returned the cached data anyway. I'd probably also add in some debounce tho. :)

    • @kunjuperath
      @kunjuperath 3 ปีที่แล้ว +1

      Thanks for replying! That makes sense and I didn't know debounce was a thing tysm!

  • @happygurha5062
    @happygurha5062 3 ปีที่แล้ว +1

    Love to see a demo on dependency injection with react context And react ui architecture patterns

  • @osamaaburabie5684
    @osamaaburabie5684 3 ปีที่แล้ว +1

    Great tutorial sir, I have a question whats the name of the extension for auto suggestions you're using.

    • @jherr
      @jherr  3 ปีที่แล้ว +2

      That would be Github Copilot. Don't believe the FUD, it's not going to take your job. But it is going to accelerate your coding like I've never seen before.

    • @osamaaburabie5684
      @osamaaburabie5684 3 ปีที่แล้ว +1

      @@jherr I've signed for it couple weeks ago but i thought ur using something else haha. thanks for the quick response btw🙏

  • @WCanyon
    @WCanyon 3 ปีที่แล้ว +1

    Thanos joke was awesome

  • @philykearney
    @philykearney 3 ปีที่แล้ว

    Great video Jack as always. 👍
    What vscode theme is that?

    • @jherr
      @jherr  3 ปีที่แล้ว +1

      Night Wolf [dark blue] with MonoLisa

    • @philykearney
      @philykearney 3 ปีที่แล้ว

      @@jherr nice, thanks 🙏

  • @0x0abb
    @0x0abb 3 ปีที่แล้ว +1

    awesome work!

  • @ab0od179
    @ab0od179 3 ปีที่แล้ว +1

    These tutorials are great but tutorials that explains logics might be even better, for example:
    I had a hard time implementing a data fetch on scroll app on how to do that from both frontend and backend.
    Same with tables that have indexing at the bottom, on how to fetch data on indexing change (again from frontend and backend).

    • @jherr
      @jherr  3 ปีที่แล้ว

      react-use has some excellent hooks to track scrolling, and you can use the data from those as dependencies on useEffects to fetch more data. Same thing with a page index. If the page index is a dependency of the fetch useEffect then the fetch will fire every time the page changes to go and get the data for that page.

    • @ab0od179
      @ab0od179 3 ปีที่แล้ว +1

      @@jherr Thanks for the advice, backend was also a challenge (in some way)

  • @reanibutani9555
    @reanibutani9555 3 ปีที่แล้ว +1

    Thank you very much Jack

  • @damonwu9658
    @damonwu9658 2 ปีที่แล้ว +1

    really good example 👍

  • @sourishdutta9600
    @sourishdutta9600 3 ปีที่แล้ว +1

    Really awesome 👌👏

  • @mansamusa559
    @mansamusa559 3 ปีที่แล้ว +1

    Can you make a video about your VS code add ons and code formatting? I really need to step up my game after seeing u code!!

  • @MrEliyahilel
    @MrEliyahilel 2 ปีที่แล้ว +1

    You are awesome, thanks a lot!

  • @erdemsoydan4117
    @erdemsoydan4117 2 ปีที่แล้ว +1

    Hi ! from official docs -> "You may rely on useMemo as a performance optimization, not as a semantic guarantee. In the future, React may choose to “forget” some previously memoized values and recalculate them on next render, e.g. to free memory for offscreen components." QUESTION: As long as there is a statement like that about useMemo, i really wonder how do people (including you:)) encourage developers to use it?

    • @jherr
      @jherr  2 ปีที่แล้ว

      It manages referential identity, primarily. So if you are constructing arrays or objects, and those are passed to other components then, as of today, those will be referentially managed to not trigger downstream effects, memos, callbacks, or updates to memoized components.

    • @erdemsoydan4117
      @erdemsoydan4117 2 ปีที่แล้ว

      @@jherr Well.. Please check what I expose in my comment :) Epecially this part: -> "In the future, React may choose to “forget” some previously memoized values and recalculate them on next render" . >>>IN FUTURE REACT MAY CHOOSE TO FORGET

    • @jherr
      @jherr  2 ปีที่แล้ว

      @@erdemsoydan4117 First off they "may" do it, and they don't now. And then there is "choose", and I read that it that under some circumstances, most likely low memory, they may go into a mode where they will invalidate this simple first order cache. (BTW, it's important to understand that `useMemo` stores only the most recent value, not all possible outputs.)
      Because dependency arrays work on ===, and === works on value for strings, numbers and booleans, and references for objects, arrays, and functions, you have to have a mechanism to control references for complex object types for derived values, and those mechanisms are useCallback and useMemo. Without them you'd have to resort to pushing the derived data into mutable state, which is incorrectly modeling the relationship between mutable state, and data that we derive from that mutable state.

    • @erdemsoydan4117
      @erdemsoydan4117 2 ปีที่แล้ว

      @@jherr Thanks for your precious time. I have been working on mid scale app and we are using Context API (yeah not redux :)) . That scale and and using context API made me have extreme attention on rerenders. So I have no problem about understanding them. I also use useMemo sometimes but whenever I use I was hesitating because of the remark about useMemo in official docs as I mentioned above. I have been waiting to ask about this to someone "a true expert" like you on this case. Thanks for your answer.
      (Also In your example, if I was working on it, I would use useCallback instead of where ever you used use Memo. e.g Count over threshold : {getCountOverThreshould()} . Is there any drawback about this? useCallback instead of useMemo?)

    • @jherr
      @jherr  2 ปีที่แล้ว

      @@erdemsoydan4117 It's been a while since I've looked at the code in this video, but if the `countOverThreshold` is a simple value I don't really understand the value of creating an accessor for it. It's certainly less surprising from an API perspective to have it be a value, as opposed to an accessor that returns a value. Can you fill me in a little on your thinking and why you believe this approach is advantageous?

  • @PhilipAlexanderHassialis
    @PhilipAlexanderHassialis 3 ปีที่แล้ว +1

    Oh.... and this is why Solid uses functions instead of primitive values in their createSignal, right? So essentially, since you invoke the function, the runtime "knows" what is dependent to something and renders only the appropriate part... is this a correct assumption Jack?

    • @jherr
      @jherr  3 ปีที่แล้ว

      Yes. Exactly.

  • @dgcp354
    @dgcp354 3 ปีที่แล้ว +1

    Ur home looks amazing

  • @illiakhomenko6405
    @illiakhomenko6405 2 ปีที่แล้ว

    amazing explanation, thank you!

  • @miguelyoutube100
    @miguelyoutube100 2 ปีที่แล้ว +1

    Thanks for the great video

  • @ShaggyKris
    @ShaggyKris 3 ปีที่แล้ว +1

    By the way, what is that diagram extension that you're using?

    • @jherr
      @jherr  3 ปีที่แล้ว

      There are a bunch, but the particular one I used was marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio I prefer the look of Excalidraw - excalidraw.com/ - but having the arrows snapping feature made it easier in this case.

    • @ShaggyKris
      @ShaggyKris 3 ปีที่แล้ว

      @@jherr Thanks!

  • @buckyhelmsmash7670
    @buckyhelmsmash7670 2 ปีที่แล้ว +1

    what's your vscode theme color?

    • @jherr
      @jherr  2 ปีที่แล้ว +1

      Night Wolf [black] and Operator Mono

  • @codezero6023
    @codezero6023 3 ปีที่แล้ว +1

    What plug-in are you using for diagrams in VS code?

    • @jherr
      @jherr  3 ปีที่แล้ว +3

      Cool, right? marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio

    • @vsakaria
      @vsakaria 3 ปีที่แล้ว

      @@jherr Very cool!

    • @Seb16291629
      @Seb16291629 3 ปีที่แล้ว

      Amazing

  • @the.solo.28
    @the.solo.28 2 ปีที่แล้ว

    Hello jack , could you please tell us , which extension use for diagram plotting in vs code

    • @jherr
      @jherr  2 ปีที่แล้ว

      Diagram.io

  • @jackh3242
    @jackh3242 3 ปีที่แล้ว +1

    React hook form might be an interesting idea for a new video 😉

    • @jherr
      @jherr  3 ปีที่แล้ว +2

      I've done a couple previously on React hook form. I might add it to a speed run though. It's a great library.

  • @novanoskillz4151
    @novanoskillz4151 3 ปีที่แล้ว

    Can someone explain the calculatePower function at 3:18 what are all of the + signs doing?

    • @dokkenrox
      @dokkenrox ปีที่แล้ว

      They're adding all the numbers in each variable together to get the total.

  • @joelbrandao4
    @joelbrandao4 2 ปีที่แล้ว

    Great content!
    Can someone explain the need for useCallback? I couldn't get it.
    Thanks!

    • @thomasstambaugh5181
      @thomasstambaugh5181 2 ปีที่แล้ว

      Heh -- I rely on the linter to tell me when I need useCallback. My perhaps naive understanding is that useCallback is the mechanism to break infinite loops in the rendering/useEffect code. As the linter explains, a function that is needed only by one specific useEffect hook can often be refactored into a local function within the hook -- eliminating the need for useCallback. Your mileage may vary. :)

  • @mkman
    @mkman 3 ปีที่แล้ว +1

    I love the pop culture references 😃

  • @rohithchittibommala2002
    @rohithchittibommala2002 3 ปีที่แล้ว

    What is theme u r using?

  • @AlexejStrelzow
    @AlexejStrelzow ปีที่แล้ว

    great video, thnx - just a small typo: it's Kent C Dodds, not Dobbs; or maybe it's a joke I don't get...

  • @BenJi-di5mn
    @BenJi-di5mn 3 ปีที่แล้ว +2

    I already know this ones gonna hurt me

  • @wobsoriano
    @wobsoriano 3 ปีที่แล้ว +4

    Since you mentioned Thanos I have a random question.
    Are you watching Loki? haha

    • @jherr
      @jherr  3 ปีที่แล้ว +2

      We are, and we like it. Haven't watched the finale though, so please no spoilers. 🤣

  • @kirillpavlovskii8342
    @kirillpavlovskii8342 2 ปีที่แล้ว

    What is .dio files extension ? How does it work ?

    • @jherr
      @jherr  2 ปีที่แล้ว

      It's handled by a diagramming tool extension. marketplace.visualstudio.com/items?itemName=hediet.vscode-drawio

  • @oussamaabdelwahed5594
    @oussamaabdelwahed5594 2 ปีที่แล้ว +1

    great content :D