Resource Hooks
Components in React can access resources without storing them as part of their state. For instance, a component can retrieve a message from a Promise or obtain styling information from a context without needing to manage that data internally. This approach simplifies component logic and promotes more efficient resource utilization.
If you read a value from a resource the use this hook.
- use is used when you read a value from resource like from Promises or context.
const ChatComponent({ chatPromise }) => {
const chat = use(chatPromise);
const themeDark = use(ThemeContext);
// ...
}
Built-in React Hooks
In React, built-in Hooks are like tools that empower your components with various functionalities. They give you the flexibility to use different features without having to create class components. You can either utilize the hooks provided by React or mix and match them to create custom hooks tailored to your needs. Here’s a list of all the pre-built hooks available in React.