Skip to content

Commit 0e581bd

Browse files
committed
update
1 parent 0749c53 commit 0e581bd

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/content/reference/react-dom/browser.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export default function SavedDraft() {
238238
239239
Like other calls to [`use`](/reference/react/use), you can call `use(browser())` conditionally. This lets a Component or custom Hook opt out of server rendering based on a condition, such as the value of a prop passed to it.
240240
241-
For example, `useTimeZone` accepts an optional initial value. If provided, that value is included in the initial HTML and rendered in the browser. If not, `use(browser())` causes the Component calling `useTimeZone` to suspend during server rendering. In the browser, `useTimeZone` reads the device's local time zone.
241+
For example, this `useTimeZone` Hook accepts an optional default value. When provided, React renders the default value in the initial HTML and in the browser. When it is not provided, `use(browser())` suspends the Component during server rendering. In the browser, `use(browser())` does not suspend, so `useTimeZone` returns the device's local time zone.
242242
243243
Click **Reload** to see the loading fallback before the user's time zone appears.
244244
@@ -248,8 +248,8 @@ Click **Reload** to see the loading fallback before the user's time zone appears
248248
import { Suspense } from 'react';
249249
import { useTimeZone } from './useTimeZone.js';
250250

251-
function TimeZone({label, initialTimeZone}) {
252-
const timeZone = useTimeZone(initialTimeZone);
251+
function TimeZone({label, defaultTimeZone}) {
252+
const timeZone = useTimeZone(defaultTimeZone);
253253
return <p>{label}: <strong>{timeZone}</strong></p>;
254254
}
255255

@@ -259,7 +259,7 @@ export default function App() {
259259
<h1>Event details</h1>
260260
<TimeZone
261261
label="Event time zone"
262-
initialTimeZone="America/New_York"
262+
defaultTimeZone="America/New_York"
263263
/>
264264
<Suspense fallback={<p>Loading your time zone...</p>}>
265265
<TimeZone label="Your time zone" />
@@ -273,12 +273,12 @@ export default function App() {
273273
import { use } from 'react';
274274
import { browser } from 'react-dom';
275275

276-
export function useTimeZone(initialTimeZone) {
277-
if (initialTimeZone !== undefined) {
278-
return initialTimeZone;
276+
export function useTimeZone(defaultTimeZone) {
277+
if (defaultTimeZone !== undefined) {
278+
return defaultTimeZone;
279279
}
280280

281-
use(browser('No initial time zone was provided.'));
281+
use(browser('No default time zone was provided.'));
282282
return Intl.DateTimeFormat().resolvedOptions().timeZone;
283283
}
284284
```
@@ -400,7 +400,7 @@ function ProductDetails({ productId, initialData }) {
400400
}
401401
```
402402
403-
This way, if `initialData` is not provided, `useBrowserQuery` skips server rendering, leaving the closest [`<Suspense>`](/reference/react/Suspense) boundary's fallback in the HTML. In the browser, `use(browser())` does not suspend, so the query library can fetch the data or read it from its client cache as usual.
403+
If `initialData` is not provided, `useBrowserQuery` skips server rendering and leaves the closest [`<Suspense>`](/reference/react/Suspense) boundary's fallback in the HTML. In the browser, `use(browser())` does not suspend, so the query library can fetch the data or read it from its client cache as usual.
404404
405405
---
406406

0 commit comments

Comments
 (0)