You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* [WIP] Add use hook API reference page
* [WIP] Update use hook API reference page based on feedback
* [WIP] use hook API ref doc: add browser API example
* [WIP] use hook API ref doc: add context, lib examples
* [WIP] use reference doc - incorporate all current feedback
* [WIP] use reference page fix typos
* use reference doc: address PR feedback from Luna, Sophia,Eli, and Lee
* Apply @harish-sethuraman's typo fixes from code review
Co-authored-by: Strek <[email protected]>
* use reference doc typo fixes
* use reference doc: update style to match other react.dev conventions
* minor fixes
* Remove client Promises, use canary labels
* Add use hook section to index, remove RSC section on components page
* Final edits
* Clarify use reference caveats
---------
Co-authored-by: Strek <[email protected]>
Copy file name to clipboardExpand all lines: src/content/reference/react/index.md
+18
Original file line number
Diff line number
Diff line change
@@ -106,6 +106,24 @@ To prioritize rendering, use one of these Hooks:
106
106
107
107
---
108
108
109
+
## Resource Hooks {/*resource-hooks*/}
110
+
111
+
*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.
112
+
113
+
To read a value from a resource, use this Hook:
114
+
115
+
- [`use`](/reference/react/use) lets you read the value of a resource like a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) or [context](/learn/passing-data-deeply-with-context).
116
+
117
+
```js
118
+
functionMessageComponent({ messagePromise }) {
119
+
constmessage=use(messagePromise);
120
+
consttheme=use(ThemeContext);
121
+
// ...
122
+
}
123
+
```
124
+
125
+
---
126
+
109
127
## Other Hooks {/*other-hooks*/}
110
128
111
129
These Hooks are mostly useful to library authors and aren't commonly used in the application code.
0 commit comments