Middle
What React hooks do you mainly use?
sobes.tech AI
Answer from AI
Basically, I use the following React hooks:
useState— for managing the local state of a component.useEffect— for performing side effects, such as data loading or subscriptions.useMemoanduseCallback— for performance optimization, to memoize values and functions.useRef— for storing mutable values that do not trigger re-renders.
Example of using useState and useEffect:
import React, { useState, useEffect } from 'react';
function Counter() {
const [count, setCount] = useState(0);
useEffect(() => {
document.title = `You clicked ${count} times`;
}, [count]);
return (
<button onClick={() => setCount(count + 1)}>
Click me
</button>
);
}