useState,
useEffect,
useLayoutEffect,
useRef,
useCallback,
useMemo,
useReducer,
userContext,
useImperativeHandle,
useDebugValue,
useDeferredValue
useId,
useOptimistic,
useInsertionEffect,
useTransition,
useSyncExternalStore
} from 'react'.
// Chưa sử dụng hooks, chỉ là UI component
return <h1> Haven't used hooks yet </h1>
}
// Sử dụng hooks, hổ trợ thêm nhiều tính năng
const [state, setState] = useState(initState);
useEffect(() => {
}, [deps])
}, [deps])
const ref = useRef();
const fn = useCallback(() => {
}, [deps])
const results = useMemo(() => {
} , [deps])
const [state, dispatch] = useReducer(reducer, initialArg, init)
const value = useContext(MyContext)
useImperativeHandle(ref, createHandle, [deps])
useDebugValue(isOnline ? 'isOnline': 'isOffline');
const deferredValue = useDeferredValue(value)
const id = useId()
const [optimisticState, addOptimistic] = useOptimistic(state, updateFn);
seInsertionEffect(setup, dependencies?)
const [isPending, startTransition] = useTransition()
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot?)
return <h1>Hooks</h1>
}