Movatterモバイル変換


[0]ホーム

URL:


Is this page useful?

Built-in React APIs

In addition toHooks andComponents, thereact package exports a few other APIs that are useful for defining components. This page lists all the remaining modern React APIs.


  • createContext lets you define and provide context to the child components. Used withuseContext.
  • lazy lets you defer loading a component’s code until it’s rendered for the first time.
  • memo lets your component skip re-renders with same props. Used withuseMemo anduseCallback.
  • startTransition lets you mark a state update as non-urgent. Similar touseTransition.
  • act lets you wrap renders and interactions in tests to ensure updates have processed before making assertions.

Resource APIs

Resources can be accessed by a component without having them as part of their state. For example, a component can read a message from a Promise or read styling information from a context.

To read a value from a resource, use this API:

functionMessageComponent({messagePromise}){
constmessage =use(messagePromise);
consttheme =use(ThemeContext);
// ...
}


[8]ページ先頭

©2009-2025 Movatter.jp