Custom Hook là cách trích xuất logic tái sử dụng từ component thành function riêng, tên bắt đầu bằng 'use'.
Ví dụ useForm(initialValues) trả về {values, handleChange, reset, errors} để quản lý state và validation của form.
A Custom Hook extracts reusable logic from a component into a standalone function prefixed with 'use'.
Example: useForm(initialValues) returns { values, handleChange, reset, errors } to manage form state and validation. To test a custom hook, use renderHook from @testing-library/react — it lets you test the hook's behavior in isolation without mounting a full component. Key benefits: separates logic from UI, easy to test, and shareable across multiple components — e.g., a single useForm hook for both registration and profile edit forms.