Skip to content

Commit 17c6783

Browse files
committed
Add a note about ErrorBoundary to state persistence docs
1 parent 4ce5289 commit 17c6783

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

versioned_docs/version-6.x/state-persistence.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export default function App() {
7272
}
7373
```
7474

75+
:::warning
76+
77+
It is recommended to use an [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) in your app and clear the persisted state if an error occurs. This will ensure that the app doesn't get stuck in an error state if a screen crashes.
78+
79+
:::
80+
7581
### Development Mode
7682

7783
This feature is particularly useful in development mode. You can enable it selectively using the following approach:
@@ -80,7 +86,7 @@ This feature is particularly useful in development mode. You can enable it selec
8086
const [isReady, setIsReady] = React.useState(__DEV__ ? false : true);
8187
```
8288

83-
While it can be used for production as well, use it with caution as it can make the app unusable if the app is crashing on a particular screen - as the user will still be on the same screen after restarting.
89+
While it can be used for production as well, use it with caution as it can make the app unusable if the app is crashing on a particular screen - as the user will still be on the same screen after restarting. So if you are using it in production, make sure to clear the persisted state if an error occurs.
8490

8591
### Loading View
8692

versioned_docs/version-7.x/state-persistence.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ export default function App() {
273273
</TabItem>
274274
</Tabs>
275275

276+
:::warning
277+
278+
It is recommended to use an [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) in your app and clear the persisted state if an error occurs. This will ensure that the app doesn't get stuck in an error state if a screen crashes.
279+
280+
:::
281+
276282
### Development Mode
277283

278284
This feature is particularly useful in development mode. You can enable it selectively using the following approach:
@@ -281,7 +287,7 @@ This feature is particularly useful in development mode. You can enable it selec
281287
const [isReady, setIsReady] = React.useState(__DEV__ ? false : true);
282288
```
283289

284-
While it can be used for production as well, use it with caution as it can make the app unusable if the app is crashing on a particular screen - as the user will still be on the same screen after restarting.
290+
While it can be used for production as well, use it with caution as it can make the app unusable if the app is crashing on a particular screen - as the user will still be on the same screen after restarting. So if you are using it in production, make sure to clear the persisted state if an error occurs.
285291

286292
### Loading View
287293

0 commit comments

Comments
 (0)