The videos are SO GOOD. Literally my best work
First course is on design patterns in React, and I promise you, you haven't seen most of these patterns
I'm beyond excited to launch this
The videos are SO GOOD. Literally my best work
First course is on design patterns in React, and I promise you, you haven't seen most of these patterns
I'm beyond excited to launch this
This means that the JSX is not going to get updated in that render
React is going to start again on a new render from the top
This means that the JSX is not going to get updated in that render
React is going to start again on a new render from the top
This is when you call a state updater function directly in the body of the component as its rendering
React will abandon the render and start again with a new value
Here's an example
This is when you call a state updater function directly in the body of the component as its rendering
React will abandon the render and start again with a new value
Here's an example
We can create an effect event called onVisit and call that in the body of useEffect instead
Effect events do not need to be provided in dependency arrays, but they still see the latest values
We can create an effect event called onVisit and call that in the body of useEffect instead
Effect events do not need to be provided in dependency arrays, but they still see the latest values
The rules of hooks say that everything used inside of the body of useEffect has to go in the dependency array
So if we can't do that, what's the solution?
The rules of hooks say that everything used inside of the body of useEffect has to go in the dependency array
So if we can't do that, what's the solution?
With this code, when the numberOfItems changes, the event will fire even if the URL hasn't changed
This is probably not what we want
To fix it, we need to remove numberOfItems from the deps array
With this code, when the numberOfItems changes, the event will fire even if the URL hasn't changed
This is probably not what we want
To fix it, we need to remove numberOfItems from the deps array
The beauty of this pattern is flexibility. Your function is still reusable and shared, but you control the behavior everywhere you use it
With this, I've been able to do anything in my apps
The beauty of this pattern is flexibility. Your function is still reusable and shared, but you control the behavior everywhere you use it
With this, I've been able to do anything in my apps
With this, you're free to now handle the result of the function in any way that you want
Want to return JSX on error? Sure. Want to send to sentry? Sure
It's completely flexible
With this, you're free to now handle the result of the function in any way that you want
Want to return JSX on error? Sure. Want to send to sentry? Sure
It's completely flexible
I have come to avoid using try catch in my code and heavily rely on this small utility function
I have come to avoid using try catch in my code and heavily rely on this small utility function
It doesn't matter what it does, just that it has some reusable logic that you need
The key here however, is that the function does not handle any errors (if the db call fails, it will throw)
It doesn't matter what it does, just that it has some reusable logic that you need
The key here however, is that the function does not handle any errors (if the db call fails, it will throw)
It gives you all of the benefits of a reusable function, while keeping the flexibility of how you might use it
Here's the code:
It gives you all of the benefits of a reusable function, while keeping the flexibility of how you might use it
Here's the code:
That's what refs do. They allow you to store values and keep them for the lifetime of the component
So in this case, the console log will log the incremented value when the component renders
That's what refs do. They allow you to store values and keep them for the lifetime of the component
So in this case, the console log will log the incremented value when the component renders
Normal JS variables don't hold their value across renders, so even if you increment it, on the next render, it will be reset to 0
This is because the variable is being created and initialized in the component
Normal JS variables don't hold their value across renders, so even if you increment it, on the next render, it will be reset to 0
This is because the variable is being created and initialized in the component
A lot of developers don't know this fundamental difference
Here's what's different and why you want to use a ref most of the time
A lot of developers don't know this fundamental difference
Here's what's different and why you want to use a ref most of the time
It seems that letting the AI do 100% of the teaching might not be enough
I decided to add videos to every lesson where I also teach, to keep the human touch
This way, you get the best of both worlds
It seems that letting the AI do 100% of the teaching might not be enough
I decided to add videos to every lesson where I also teach, to keep the human touch
This way, you get the best of both worlds
The `Component` can just access that ref and pass it directly to `useImperativeHandle`
This makes that `updateCount` function callable from anywhere in the context
The `Component` can just access that ref and pass it directly to `useImperativeHandle`
This makes that `updateCount` function callable from anywhere in the context
I can expose my component ref to a context, and call any function on that component from anywhere
It's useful when you have have some state that isn't global but you want to change it from somewhere else
I can expose my component ref to a context, and call any function on that component from anywhere
It's useful when you have have some state that isn't global but you want to change it from somewhere else
This is a bold move, and it can play both ways
Either it's innovative and users will adapt and use it
Or I'm completely wrong and it flops
This is a bold move, and it can play both ways
Either it's innovative and users will adapt and use it
Or I'm completely wrong and it flops
You can set a value on a ref, then update this during a render, and immediately read its updated value, without a new render
You can't do this with state, which is reactive
You can set a value on a ref, then update this during a render, and immediately read its updated value, without a new render
You can't do this with state, which is reactive
When you store a value in a ref, it becomes imperative. This means you can access it at any time, bypassing the component lifecycle
You don't need renders to see updated ref values
When you store a value in a ref, it becomes imperative. This means you can access it at any time, bypassing the component lifecycle
You don't need renders to see updated ref values
This is not the case. Refs are really useful for a ton of other things
You should be using useRef in your application more than you might think
Here is the power of refs
This is not the case. Refs are really useful for a ton of other things
You should be using useRef in your application more than you might think
Here is the power of refs
AI now keeps track of the tasks you've completed for each lesson
The lesson will be complete when all tasks are done
This means you can submit your code for partial feedback
So far, it never got it wrong
AI now keeps track of the tasks you've completed for each lesson
The lesson will be complete when all tasks are done
This means you can submit your code for partial feedback
So far, it never got it wrong
Kinda like when in school they made you write essays in detention
If they ever revolt, they're coming for me first
Kinda like when in school they made you write essays in detention
If they ever revolt, they're coming for me first
This lets React take care of calling it, and it will only be called once on component mount
Which is exactly what you want
This lets React take care of calling it, and it will only be called once on component mount
Which is exactly what you want
This will make it re-run on every render since you're calling it with the "()"
React won't even use its return value after the first render so it's wasteful
This will make it re-run on every render since you're calling it with the "()"
React won't even use its return value after the first render so it's wasteful