I'm usually not using custom-hooks because I lack the imagination where to use them, and video just gave me 2 great ideas, thanks ! :) It would be great if you could do more videos regarding different common custom-hooks like these ones.
Yup, I think we don't have the coders' minds YET!!! or maybe we need to throw ourselves into the fire of a working environment to get creative and find use cases of various programming concepts.
It's worth taking note that the views counts for this series dropped from 216,154 views (1st video) to 42,597 views (last video), maybe means there 's a learning curve; and I am proud that I watched all and code along. Great work Kyle!!!
Great series. You really helped me figure out the difference between the different types of react hooks. I was not having the easiest time trying to figure it out looking through other people's code. Thanks man. Keep the videos coming. You're great at what you do!
React and hooks are so freaking fun. I just got my first job as dev and first task was creating a frontend all with hooks, apollo graphql, typescrypt and redux. When you figure it out you can play around with data really nicely. PS great channel
useLocalStorage hook should be implemented in React by default, it makes the operations on local storage so clean i can't imagine doing it the "default" way again. Thanks for another great tutorial! :)
This example is perfect for me! I was creating a React project to manage Arkham Horror LCG stuff, and just had to saved in a big ol state. But for saving games serverlessly, local storage was gonna be the way I handled it. This idea will meld in nicely with saving my data, woot!
Thanks for the great series on react hooks. Will definitely have to go through it a 2nd time to let all the details sink in. But I have good overview of it now.
Before knowing this...I also use to the same thing....saving things in local storage....today he made this a react custom hook Kyle do knows how to use his tools appropriately and in efficient way
Is "if(initialValue instanceof Function) return initialValue();" necessary? Because if using a console.log() to print out whether it's true or false, we'd always get "false". So, what's the reason to use this line of code?
Thanks for the good video! But I think your useTimeout function should be like something like below. export function useTimeOut(callback, delay, dependency) { const callbackRef = useRef(); const timeOutRef = useRef(); useEffect(() => { console.log('callback update'); callbackRef.current = callback; }, [...dependency]); ... } because like you mentioned, callback without 'useCallback' is different always.
Now, why not to bring this to another level? build your custom hook useStateStore, then create useReducer inside, import store hook into your components and voila, you have global store like Redux. Also, you can privide that store using context api... :)
actually i tried the same code with a signle function , in the same component, and it works fine, but i cant use useEffect inside a function,for that i just made a if check, and if we want to use a useEffect inside a function, that must be a react component, or a custom hook, that is fine, but here the important thing is with a custom hook we can use it several times, instead of writing the code again and again, thanks for the awesome video,
Kyle, how do you get the localstorage in chrome to update when the state is changing? I had to refresh the localstorage to see the new value. Can you please help?
Why on the useEffect does React complain about ' key ' being a missing dependency? I've seen this in a couple tutorials now, has something changed with React?
Can someone explain what he does starting 5:02? "And now we what we can do is use a function version...". As opposed to what? Does writing an explicit return statement make it a "function version"?
great video, but I don't get why the input wouldn't be persisted in the first place. Isn't the value of the input field the useState "name," whose value would persist through refreshes? So after you type something in and set the useState to that input, after a re-render why wouldn't the input just reset it value to the useState value that's still there? Thanks a ton
Really, really awesome video!! as always by the way I wanted to ask that can we make android apps in like plain javascript without using React Native and can we use js with C++ or python?Thanks!!
Android supports c++ natively and has its own NDK but why you'd want to mix it with js im not sure. PWA is basically using js and c++ just the c++ is written by the browser vendor. Its all possible but the practicality of it will depend on the kind of software you want to write.
@@fredhair hey there!! actually, I was thinking that it would be easier to make a user interface if we combine c++ with js, HTML, AND CSS maybe Node js would do it.
hello i have one question i want to use the usedispatch and useselector outside the function and class component. i have a helper.js in which i am trying to call the api by using redux saga for that i need to use usedispatch and then the response i want to get through useselector in same helper class. any idea how to achieve this
Can someone please explain: why assign a function in useState will reduce the call of localstorage, like he said in 5:20, "only call this once when first time rendering the component, not everytime render". I mean this function in useState still returns the result of function savedValue, so why not write like const [value, setValue] = useState(savedValue(key, initialValue)) ? Can anyone explain it?
I don't know if you already found your answer, but just in case... When using a function as initial value for useState, we need to practice "CURRYING" or wrapping function executions in another function, like this: useState(( ) => someFunc( )) as opposed to just: useState(someFunc( )). This way, someFunc doesn't get called unnecessarily every re-render. It's not noticeable on small apps but treat it as an optimization with the way useState hook works. In the video, the data from local storage is only read at the initial component render. EDIT: Try putting a console.log( ) on the function and compare. The one with no currying will show the log every keystroke.
at 1:19, what is the alternative for localstorage?, can we use useContext or redux for global storage, or even though if we use useContext or redux, the input value will become empty?
In getSavedValue function: "if (savedValue) return savedValue" What if savedValue is false or 0 or an empty string? Shouldn't it be like: "if (savedValue !== null) return savedValue" or am i mistaken?
So lost. I cannot follow this video. Does anyone know of something even easier than this? I am like 10 hours into these and I feel like I know nothing.
I'm usually not using custom-hooks because I lack the imagination where to use them, and video just gave me 2 great ideas, thanks ! :)
It would be great if you could do more videos regarding different common custom-hooks like these ones.
Yup, I think we don't have the coders' minds YET!!! or maybe we need to throw ourselves into the fire of a working environment to get creative and find use cases of various programming concepts.
i have finished all this react hook series in this channel, literally worth every seconds. Thanks Kyle
damm, i am hooked now
get out
what are yuo 14?
I see what you did there
Ahhhaha I love the pun😂
I like how you react to this vid
You have the best tutorials. You never add a bunch of unnecessary commentary and for that I thank you.
The way you explain it, i am in awe of it.
It's worth taking note that the views counts for this series dropped from 216,154 views (1st video) to 42,597 views (last video), maybe means there 's a learning curve; and I am proud that I watched all and code along. Great work Kyle!!!
You're really simplifying the web for me
this video is so underrated, it should have like a billion likes. thank you
you are one of the best that explains, thanks a lot for all the useful information
Great series. You really helped me figure out the difference between the different types of react hooks. I was not having the easiest time trying to figure it out looking through other people's code. Thanks man. Keep the videos coming. You're great at what you do!
Wow man. You really have made the web simplified for us to build our project. Awesome content as always👏
React and hooks are so freaking fun. I just got my first job as dev and first task was creating a frontend all with hooks, apollo graphql, typescrypt and redux. When you figure it out you can play around with data really nicely. PS great channel
Id love to have that kida job
useLocalStorage hook should be implemented in React by default, it makes the operations on local storage so clean i can't imagine doing it the "default" way again. Thanks for another great tutorial! :)
Please keep this up this is really great. I just finished your entire hooks Playlist. Thank you😊
Thanks so much for these videos, they are very concise and easy to follow.
i use redux toolkit and it helps me a lot. but really thanks for the video. we love u
Thanks for simplifying react for us!
Your video's is awesome. It's so simple to understand what you are saying! Thank you so much!
Thanks Kyle... These videos are really helpful for beginners.
I am "hooked" to this channel..
This example is perfect for me! I was creating a React project to manage Arkham Horror LCG stuff, and just had to saved in a big ol state. But for saving games serverlessly, local storage was gonna be the way I handled it. This idea will meld in nicely with saving my data, woot!
best explanation ever!! thank you
Great tutorial! Thank you for the explanation! 💛
Superb kyle, every thing is clear
Thanks for the great series on react hooks. Will definitely have to go through it a 2nd time to let all the details sink in. But I have good overview of it now.
Greatly explained the concept!
Thanks a lot for this video. learnt something new today :)
Thank you! This is very much simplified to me!
Awesome explanation, genius guy
Before knowing this...I also use to the same thing....saving things in local storage....today he made this a react custom hook
Kyle do knows how to use his tools appropriately and in efficient way
i have three letters for this video WTF ---- hands-down best explanation of custom hooks... thanks Kyle.
TH-cam should make a two like button only for your channel because I would give you two likes
really great tut. thanks dude
very nicely explained
One question, why will initialValue be a function?
Thanks for this great tutorial.
This was a great example... However if this example would help to stay login in after refreshing ..would be great
awesome learnt about local storage and hooks
thx already shared to Twitter
Thank you
Great explanation kyle ..please make on one video Event loop
great tutorial series, thank you so much
You can even add a deleteItem function inside useLocalStorage to delete the item if the user needs to
Is "if(initialValue instanceof Function) return initialValue();" necessary? Because if using a console.log() to print out whether it's true or false, we'd always get "false". So, what's the reason to use this line of code?
Hi Kyle, I really like your videos and the quality of the image. What camera are you using? Thanks!
It is a logitech brio shooting in 1080p
@@WebDevSimplified Thanks a lot!
Thanks for the good video!
But I think your useTimeout function should be like something like below.
export function useTimeOut(callback, delay, dependency) {
const callbackRef = useRef();
const timeOutRef = useRef();
useEffect(() => {
console.log('callback update');
callbackRef.current = callback;
}, [...dependency]);
...
}
because like you mentioned, callback without 'useCallback' is different always.
Thanks!
Thank you for the support!
Now, why not to bring this to another level? build your custom hook useStateStore, then create useReducer inside, import store hook into your components and voila, you have global store like Redux. Also, you can privide that store using context api... :)
Thank you very much! great video
Hey, a question, does a hook persist and share the state through multiple component, like context-provider works?
amazing, thanks
This is awesome, thanks so much.
actually i tried the same code with a signle function , in the same component, and it works fine, but i cant use useEffect inside a function,for that i just made a if check,
and if we want to use a useEffect inside a function, that must be a react component, or a custom hook, that is fine, but here the important thing is with a custom hook we can use it several times, instead of writing the code again and again, thanks for the awesome video,
Thanks a lot for the video.
liked it, loved it, just the thing I was looking for. Thanks very much.
thanks!
Good job man!
how can initialvalue be a function. i didn't get that part. can anyone explain please
Great Tutorial on Custom Hooks in React. Thanks, Kyle
{2022-02-24}, {2022-08-02}, {2022-11-16}, {2023-06-28}
Hello, it's fun to write a custom hook, but I wonder if this custom hook is better than Redux or the same, or worse?
Can some1 explain to me why using a function in useState can help reduce the call on localstorage ?😊
so custom hooks combination of function and component we take argument and return / without return . also we can useEffect within it .
Great little video, as usual, Kyle.
this would definitely be helpful in react native
😀
Hey Bharat
Have you built any react projects recently? Are you open to internship/job opportunities in software development ?
thanks, sir for such awesome video, if you possible please make some videos on react recoil.
Kyle, how do you get the localstorage in chrome to update when the state is changing? I had to refresh the localstorage to see the new value. Can you please help?
just a little improvement, for the the custom hook we can use named-parameters, in that way the order of the parameters does not matter.
It just works!
nice bro thanks for giving this video
Imagine getting hearted by one of the best teachers on the internet
Why on the useEffect does React complain about ' key ' being a missing dependency? I've seen this in a couple tutorials now, has something changed with React?
Can someone explain what he does starting 5:02? "And now we what we can do is use a function version...". As opposed to what? Does writing an explicit return statement make it a "function version"?
Hey, thanks again for another video! Can you make on related to wherr to store jwt on the client side?
whats the configuration of your computer?
Even though how simple the last hook was it can be pretty handy in debugging stuff
Hey Rohin
Have you been working on any react projects currently? Are you open to internship/job opportunities in software development ?
Awesome, thank you
ty.
Do you have a course with Hooks + Redux ?
I don't understand, why don't we use useRef instead of useState?
We could prevent un necessary re-renders right?
He used usestate so he could log and show the input changing on each keystroke, he needs the re render for that
Wow thanks
Mind blow video
great video, but I don't get why the input wouldn't be persisted in the first place. Isn't the value of the input field the useState "name," whose value would persist through refreshes? So after you type something in and set the useState to that input, after a re-render why wouldn't the input just reset it value to the useState value that's still there? Thanks a ton
Because a rerender is not the same as a reload
Hi Kyle please make a video on Instant search filter like youtube on react.
Really, really awesome video!! as always by the way I wanted to ask that can we make android apps in like plain javascript without using React Native and can we use js with C++ or python?Thanks!!
I know one way to use js with python is "eel" but not don't know about C++ with js.
Android supports c++ natively and has its own NDK but why you'd want to mix it with js im not sure. PWA is basically using js and c++ just the c++ is written by the browser vendor. Its all possible but the practicality of it will depend on the kind of software you want to write.
@@fredhair hey there!! actually, I was thinking that it would be easier to make a user interface if we combine c++ with js, HTML, AND CSS maybe Node js would do it.
I don't get why "useUpdateLogger" needs to use useEffect at all? Since it's prop/input parameter is constantly changing, why do you need useEffect?
hello i have one question
i want to use the usedispatch and useselector outside the function and class component. i have a helper.js in which i am trying to call the api by using redux saga for that i need to use usedispatch and then the response i want to get through useselector in same helper class. any idea how to achieve this
Can someone please explain: why assign a function in useState will reduce the call of localstorage, like he said in 5:20, "only call this once when first time rendering the component, not everytime render". I mean this function in useState still returns the result of function savedValue, so why not write like const [value, setValue] = useState(savedValue(key, initialValue)) ? Can anyone explain it?
I don't know if you already found your answer, but just in case...
When using a function as initial value for useState, we need to practice "CURRYING" or wrapping function executions in another function, like this:
useState(( ) => someFunc( ))
as opposed to just: useState(someFunc( )).
This way, someFunc doesn't get called unnecessarily every re-render. It's not noticeable on small apps but treat it as an optimization with the way useState hook works. In the video, the data from local storage is only read at the initial component render.
EDIT: Try putting a console.log( ) on the function and compare. The one with no currying will show the log every keystroke.
Is there a way to change the key somehow, since I would love to have mutliple keys for every users that let's say loggs into my page.
This is great!
Can i say custome hooks have the same purpose like HOC in class component.
render props and hoc do the same kind of thing i guess
I ate these fucking hooks bcz of you, the great Kyle
at 1:19, what is the alternative for localstorage?, can we use useContext or redux for global storage, or even though if we use useContext or redux, the input value will become empty?
Great, thank you :)
love me some cutsom hooks
Why to create useUpdateLogger if you just can write console.log(value)?
Dude how are you making your hair like that every day :D
In getSavedValue function: "if (savedValue) return savedValue" What if savedValue is false or 0 or an empty string? Shouldn't it be like: "if (savedValue !== null) return savedValue" or am i mistaken?
Awesome!
So lost. I cannot follow this video. Does anyone know of something even easier than this? I am like 10 hours into these and I feel like I know nothing.
Same here
@@Viv-m8j been a paid dev for over a year now. Still confused lol
Amazing video. I'm in love with you!