Truyền function vào useState thay vì giá trị trực tiếp: useState(() => computeExpensiveValue()).
- Function này chỉ chạy một lần khi mount, không chạy lại mỗi render.
- Hữu ích khi khởi tạo state từ localStorage hay tính toán phức tạp:
useState(() => JSON.parse(localStorage.getItem('key'))).