I am using redux-persist to persist my app’s state.It all works fine but once a user encounter an error, they get stuck on that particular broken state. I am trying to use a React error boundary to achive a scenario where I could reset the the app’s state before crashing, so that a refresh would boot a fresh copy of the app.
Think I might be missing some Expo internal to hook up to
import * as React from "react"
import { connect } from "react-redux"
import { View, Text } from "react-native"
class ErrorBoundaryClass extends React.Component<any, { hasError: boolean }> {
constructor(props) {
super(props)
this.state = { hasError: false }
}
public componentDidCatch(error, info) {
// Display fallback UI
this.setState({ hasError: true })
this.props.dispatch({ type: "RESET" })
}
public render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <View><Text>Something went wrong.</Text></View>
}
return this.props.children
}
}
export const ErrorBoundary = connect()(ErrorBoundaryClass)