react 全局监听报错,监听白屏

componentDidCatch(error, info) - 如果 render() 函数抛出错误,则会触发该函数。

 getDerivedStateFromError(error) - 此生命周期会在后代组件抛出错误后被调用。 它将抛出的错误作为参数,并返回一个值以更新 state

原文地址:https://www.cnblogs.com/xiaoyaoweb/p/14787320.html