| title | 내장 React API |
|---|
Hook과 컴포넌트 외에도 react 패키지는 컴포넌트를 정의하는데 유용한 몇 가지 API를 가지고 있습니다. 이 페이지는 최신 React API를 모두 나열합니다.
createContextlets you define and provide context to the child components. Used withuseContext.lazylets you defer loading a component's code until it's rendered for the first time.memolets your component skip re-renders with same props. Used withuseMemoanduseCallback.startTransitionlets you mark a state update as non-urgent. Similar touseTransition.addTransitionTypelets you specify the cause of a Transition. Used withstartTransitionand<ViewTransition>.actlets you wrap renders and interactions in tests to ensure updates have processed before making assertions.cachelets you cache the result of a data fetch or computation.cacheSignallets you know when thecache()lifetime is over.captureOwnerStackreads the current Owner Stack in development and returns it as a string if available.
8c68ae8d2410abe59f351195780c6f8ea9f50904
Resource를 State의 일부로 포함하지 않고도 컴포넌트에서 Resource에 액세스할 수 있습니다. 예를 들어, 컴포넌트는 Promise에서 메시지를 읽거나 Context에서 스타일 정보를 읽을 수 있습니다.
Resource에서 값을 읽으려면 다음 API를 사용하세요.
function MessageComponent({ messagePromise }) {
const message = use(messagePromise);
const theme = use(ThemeContext);
use(browser());
// ...
}