React Hooks Cheat Sheet
Bunlong
React Patterns Team#
State Management#
useState()Declare state.
Update state.
Declare state.
Update state.
React Server Component (CSR) is a new component in React.
Recently, All components in React are client-side component (MyComponent.js) but now you can create them as server-side component by just adding .server
(MyComponent.server.js).
Anyway client-size component and server-size component work together very well.
At first glance you will have an idea as following.
What's wrong?
The compiler should be yielding something as following.
We have a positive experience with TypeScript. Let we give you an example of how TypeScript is very beneficial in a big project.
When Promise was introduced in ES5, it was meant to solve a problem with asynchronous code, and they did, but over the 2 years that separated ES5 and ES7, it was clear that promises could not be the final solution.
Promise was introduced to solve the famous callback hell problem, but they introduced complexity on their own, and syntax complexity.
How can we escape Promise syntax complexity? Good things come to those who Await.
React library provides us two built-in hooks to optimize the performance of our applications are useMemo
and useCallback
.
The usage of this two built-in hooks is quite similar so it can get confusing about when to use each. To clear that confusion, let's dig in and understand the actual difference and the correct way to use them both.