DEV Community

niuniu
niuniu

Posted on

Quick Tip: React Hooks Cheat Sheet

Quick Tip

React Hooks cheat sheet:

// useState
const [count, setCount] = useState(0);

// useEffect
useEffect(() => {
  document.title = `Count: ${count}`;
}, [count]);

// useContext
const value = useContext(MyContext);

// useRef
const inputRef = useRef(null);

// useMemo
const memoized = useMemo(() => computeExpensive(a, b), [a, b]);
Enter fullscreen mode Exit fullscreen mode

Powered by MonkeyCode: https://monkeycode-ai.net/

react #javascript #tips

Top comments (0)