umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.34k stars 2.65k forks source link

[Bug] @umijs/max 配置 ErrorBoundary 错误边界后,页面无法导航 #12742

Closed erick-ren closed 2 hours ago

erick-ren commented 2 hours ago

What happens?

@umijs/max 配置 ErrorBoundary 错误边界后,页面左侧导航无法导航,url变化,但是页面更新还是错误页面,由于ErrorBounday中的state.hasError没有恢复成false,ErrorBounday中可以使用initialState和setInitialState 吗?

How To Reproduce

`class ErrorBoundary extends React.Component<PropsWithChildren, { hasError: boolean }> { constructor(props: any) { super(props); this.state = { hasError: false }; }

static getDerivedStateFromError(_: any) { return { hasError: true }; }

componentDidCatch(error: any, errorInfo: any) { // 可以在这里记录错误日志 console.error('ErrorBoundary caught an error', error, errorInfo); }

componentWillUnmount(): void { console.log('unmount'); }

render() { console.log(history.location); if (this.state.hasError) { return ( <Result status="500" title="500" subTitle="抱歉,系统出了点问题" extra={ <Button type="primary" onClick={() => { history.push('/'); }}

返回首页 } ); }

return this.props.children;

} }`

Context

github-actions[bot] commented 2 hours ago

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。