Clearly spoken, well structured, to the point, no umming and arring... These videos are fantastic.
@adeoyeadela4 жыл бұрын
Wow I have spent more than 48hrs solving a problem with re-rendering but the last 5 minutes of this video saved my ass... :) thanks Ben
@gustavolsilvano5 жыл бұрын
You're awesome! This is one of the best react channels on youtube
@bawad5 жыл бұрын
Thank you!
@dasnipa5205 жыл бұрын
wow this is extremely helpful, thank you my inner coding god
@trentmiles56163 жыл бұрын
Dunno if anyone cares but if you guys are bored like me during the covid times you can stream all of the latest movies and series on instaflixxer. Have been watching with my gf for the last couple of months :)
@kobeshepard97763 жыл бұрын
@Trent Miles yup, I have been watching on InstaFlixxer for months myself :)
@WrongAkram5 жыл бұрын
You are awesome, thanks for making these types of videos!
@thisisgksingh3 жыл бұрын
Amazing tutorial on useMomo hook. Thanks for this Ben.
@WaterJay5 жыл бұрын
I start to think react might be going down a road of over complexity things. In order to do efficient rendering, u have to watch out all sorts of performance pitfall, considering react memo, usecallback, usememo along the way and pick the right dependency. This wouldn’t even be a problem if u you only change/update the value where it has been changed instead of do a freaking diff and render at any chance it get. Used to be react fan btw, now I’m thinking what’s the point and all these starts to get silly. All of a sudden, reactive programming looks charming
@DiegoJutsu4 жыл бұрын
You are not alone
@xerxius54464 жыл бұрын
I love this hooks series. Thanks for the videos !
@neelakshsharma49364 жыл бұрын
Amazing stuff. After reading the hooks docs, if I don't get what it tries to convey, I refer these videos and it pretty clearly.
@Kr00kan2 жыл бұрын
Straight to the point. Great video Ben!
@Oxcorp5 жыл бұрын
A way you can find the largest word in an array is with the Array.reduce() method, here's how I did it: const longestWord = ['some', 'words'].reduce((biggest, curr) => { return curr.length > biggest.length ? curr : biggest }
@EndiFreeKolesio5 жыл бұрын
It can get even easier with Array.find ;)
@converter5 жыл бұрын
this is not algorithm channel :P ofcourse there's different ways to do that
@nikosspiropoulos84174 жыл бұрын
great video!!! explains a lot about both useCallback AND useMemo !!!
@markdesign13545 жыл бұрын
Great video! Quick Question: Isn't this same as calling computeLongestWord inside useEffect and setting longestword with useState?
@bawad5 жыл бұрын
kind of, that would cause a rerender though
@markdesign13545 жыл бұрын
@@bawad I just did a quick test, seems to behave the same for me. Am I missing something? codesandbox.io/s/react-hooks-usememo-example-lowde
@bawad5 жыл бұрын
yeah they would have similar behavior but calling the setter in useEffect would cause another render
@markdesign13545 жыл бұрын
@@bawad ah!.. got it. after I put a console.log outside computeLongestWord(), I can see the extra render without useMemo ! Interesting.., computeLongestWord() is still only called once in both scenarios, so performance seems to be negligible. Thanks for helping me understand it finally !!!
@joracardanovsky41925 жыл бұрын
I'm not sure why would you specify the function itself in the use memo second parameter. In which case would that be useful? By the way, thanks for your videos, extremely useful
@shabeebck30574 жыл бұрын
So basically useMemo is using to execute a function when a change value of its given dependency, thats amazing !
@AntiMassovka4 жыл бұрын
Nice, bro. Like the way you code. Thanks for the info!
@matijatu4 жыл бұрын
I'm wondering if there is a reason why the unmount is inside of a separate useEffect. I'm talking about useFetch @ 1:50
@alecs63265 жыл бұрын
Great channel thanks for the awesome content!
@harishp96865 жыл бұрын
Thanks for awesome contents... could you please create a video on setting monorepo with cra and typescript?
@bawad5 жыл бұрын
sure
@harishp96865 жыл бұрын
@@bawad also please include redux
@markovujanic4 жыл бұрын
Thanks Ben, this is really useful in context explanation.
@rediculiqi41364 жыл бұрын
This was very helpful for me , please make some more of those , with optimization performance topics
@jamesjohnson53865 жыл бұрын
Is there any reason why you put setState in a dependency array for useEffect?
@bawad5 жыл бұрын
because if setState changes, I want to use the new value inside useEffect though setState is unlikely to change
@florian_2065 жыл бұрын
@@bawad it will not change. "React guarantees that setState function identity is stable and won’t change on re-renders. This is why it’s safe to omit from the useEffect or useCallback dependency list." reactjs.org/docs/hooks-reference.html#usestate
@andrewking11734 жыл бұрын
Thank you for these!! Needed these for work :D
@MrDevianceh5 жыл бұрын
Just wanted to say, i love the hooks series :) Maybe cover creating custom hooks and things like that :)
@bawad5 жыл бұрын
Any particular custom hook you'd like to see made?
@jora54832 жыл бұрын
absolutely brain-melting!!
@dhruvilpatel8564 жыл бұрын
@Ben Awad, Can we put computeLongestWord function inside useMemo (just above we call it) instead of putting it outside of component? (The point is to avoid passing as dependency)
@bawad4 жыл бұрын
> The point is to avoid passing as dependency What do you mean by that? Putting it outside the component would allow you to avoid passing it as a dep
@dhruvilpatel8564 жыл бұрын
@@bawad what if in situations where we want to export this component, does putting the function outside of it still work?
@bawad4 жыл бұрын
Yeah
@colloidalsilver1775 жыл бұрын
This was awesome but where did “arr” come from?
@bawad5 жыл бұрын
it's the parameter github.com/benawad/react-hooks-tutorial/blob/4a5200a39a9b06a1df9ee6afd68153a47ed847af/src/App.js#L4
@BobbyBundlez3 жыл бұрын
@@bawad lolz
@ivanbadyulya55625 жыл бұрын
What is the extension you use for block context underline?
@bawad5 жыл бұрын
I'm actually not sure what is causing that. Here are my settings though benawad.com/plugins
@tunvirrahman95043 жыл бұрын
how to test "ComputeLongestWord"?
@Isha30065 жыл бұрын
Could you please show, How we could use useMemo() with async await
@bawad5 жыл бұрын
I wouldn't, I would pick useEffect for that
@AshishRawat-zl6te4 жыл бұрын
Really amazing work Man. Just a suggestion- It would be good if u give the link to a code sandbox or codepen.io for the code, which would be really helpful for ur subscribers.
@stevereid6365 жыл бұрын
Eslint now complains that computeLongestWord is not a valid dependency in useMemo when employing your recommended solution of relocating the function outside?
@bawad5 жыл бұрын
does eslint want you to do: useMemo(() => computeLongestWord(data), [data, computeLongestWord])
@stevereid6365 жыл бұрын
@@bawad Not when computeLongestWord is located outside the App. It does like it being a dependency of useMemo when it's outside
@stevereid6365 жыл бұрын
@@bawad Here's the message: function computeLongestWord(arr: any): string | any[] React Hook useMemo has an unnecessary dependency: 'computeLongestWord'. Either exclude it or remove the dependency array. Outer scope values like 'computeLongestWord' aren't valid dependencies because mutating them doesn't re-render the component.eslint(react-hooks/exhaustive-deps)
@bawad5 жыл бұрын
oh, just remove computeLongestWord from the dep list useMemo(() => computeLongestWord(data), [data])
@stevereid6365 жыл бұрын
@@bawad It's just that you say in the video that computeLongestWord should be in the dep list?
@alocer15 жыл бұрын
.json url was dead. found another copy here raw.githubusercontent.com/ajzbc/kanye.rest/quotes/quotes.json
@trungnguyen59474 жыл бұрын
Another way to find the longest word: function computeLongestWord(data) { if (!data) { return []; } const longestWord = JSON.parse(data) .map((sentence) => sentence.split(' ')) .reduce((prevValue, currValue) => [...prevValue, ...currValue]) .reduce((longest, curr) => (curr.length > longest.length ? curr : longest)); return longestWord; }
@__greg__4 жыл бұрын
Very helpful, thanks!
@costeachitorog53225 жыл бұрын
thanks man
@stealthysubie4 жыл бұрын
You're the best man!
@alexey97965 жыл бұрын
Thanks, but you should return an empty string not an empty array
@bawad5 жыл бұрын
Why
@alexey97965 жыл бұрын
Ben Awad I was texting about the computeLongestWord function. Why the positive results is a string, but if there isn’t data - it’s an array? I see types inconsistency in this case
@bawad5 жыл бұрын
oh I see, yeah idk why I did that your right empty string makes more sense
@touradhadrami6530 Жыл бұрын
@vipulchodankar624 жыл бұрын
Nice.
@lardosian4 жыл бұрын
Kanye Rest lol!!!
@PouyaAtaei5 жыл бұрын
Hey mate, great material. But just slow down, chill, and explain in good harmony. I can see that you're definitely a good practitioner, but when it comes to teaching, well, it's far away from getting there.... a good example of a coding teacher can be Stephen Grider on Udemy... typing so fast and going through things so quickly doesn't make it cool, it just makes it stressful.