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
@@ -215,6 +223,68 @@ These options are merged with the `options` specified in the individual screens,
215
223
216
224
See [Options for screens](screen-options.md) for more details and examples.
217
225
226
+
### Screen layout
227
+
228
+
A screen layout is a wrapper around each screen in the group. It makes it easier to provide things such as a common error boundary and suspense fallback for all screens in a group:
229
+
230
+
<TabsgroupId="config"queryString="config">
231
+
<TabItemvalue="static"label="Static"default>
232
+
233
+
```js
234
+
constMyStack=createNativeStackNavigator({
235
+
groups: {
236
+
Modal: {
237
+
// highlight-start
238
+
screenLayout: ({ children }) => (
239
+
<ErrorBoundary>
240
+
<React.Suspense
241
+
fallback={
242
+
<View style={styles.fallback}>
243
+
<Text style={styles.text}>Loading…</Text>
244
+
</View>
245
+
}
246
+
>
247
+
{children}
248
+
</React.Suspense>
249
+
</ErrorBoundary>
250
+
),
251
+
// highlight-end
252
+
screens: {
253
+
/* screens */
254
+
},
255
+
},
256
+
},
257
+
});
258
+
```
259
+
260
+
</TabItem>
261
+
<TabItemvalue="dynamic"label="Dynamic">
262
+
263
+
```jsx
264
+
<Stack.Group
265
+
// highlight-start
266
+
screenLayout={({ children }) => (
267
+
<ErrorBoundary>
268
+
<React.Suspense
269
+
fallback={
270
+
<View style={styles.fallback}>
271
+
<Text style={styles.text}>Loading…</Text>
272
+
</View>
273
+
}
274
+
>
275
+
{children}
276
+
</React.Suspense>
277
+
</ErrorBoundary>
278
+
)}
279
+
// highlight-end
280
+
>
281
+
{/* screens */}
282
+
</Stack.Group>
283
+
```
284
+
285
+
</TabItem>
286
+
</Tabs>
287
+
218
288
### Navigation key
219
289
220
290
Optional key for a group of screens. If the key changes, all existing screens in this group will be removed (if used in a stack navigator) or reset (if used in a tab or drawer navigator):
@@ -227,11 +297,13 @@ The name of the group is used as the `navigationKey`:
227
297
```js
228
298
constMyStack=createNativeStackNavigator({
229
299
groups: {
300
+
// highlight-next-line
230
301
User: {
231
302
screens: {
232
303
/* screens */
233
304
},
234
305
},
306
+
// highlight-next-line
235
307
Guest: {
236
308
screens: {
237
309
/* screens */
@@ -246,8 +318,11 @@ This means if a screen is defined in 2 groups and the groups use the [`if`](stat
0 commit comments