use() 훅
Promise나 Context를 직접 읽을 수 있는 새로운 훅입니다. 조건부 호출도 가능합니다.
function UserProfile({ userPromise }) {
const user = use(userPromise);
return <h1>{user.name}</h1>;
}
// Context 읽기
function Theme() {
const theme = use(ThemeContext);
return <div style={{ color: theme.primary }}>...</div>;
}Actions
function UpdateForm() {
const [state, formAction] = useActionState(updateUser, initialState);
return <form action={formAction}>...</form>;
}
댓글 0