@conecli/cone-render 0.8.15-beta.5 → 0.8.15-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import React from 'react'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import React, { Suspense, lazy } from 'react'
|
|
1
|
+
import React, { Suspense, lazy } from 'react'
|
package/package.json
CHANGED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: lichang68
|
|
3
|
-
* @Date: 2022-10-31 20:27:51
|
|
4
|
-
* @LastEditTime: 2022-11-01 11:05:23
|
|
5
|
-
* @LastEditors: lichang68
|
|
6
|
-
* @Description: 错误边界,是一个React组件,只能是class组件,可以捕获发生在子组件树任何位置的js错误,并打印这些错误,同时展示降级UI,并不会渲染发生崩溃的子组件树。
|
|
7
|
-
* 包裹ContainerFloorList,捕获isv h5楼层渲染时的错误异常,并做屏蔽处理
|
|
8
|
-
* @FilePath: /shop-react/Users/cdlichang1/Documents/work/workSpace/cone-render/src/components/ErrorBoundary.jsx
|
|
9
|
-
*/
|
|
10
|
-
import React from 'react'
|
|
11
|
-
import { Text } from '@tarojs/components'
|
|
12
|
-
export default class ErrorBoundary extends React.Component {
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
this.state = {
|
|
16
|
-
hasError: false,
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static getDerivedStateFromError(error) {
|
|
21
|
-
// 更新 state 使下一次渲染能够显示出错降级后的 UI
|
|
22
|
-
return {
|
|
23
|
-
hasError: true
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
componentDidCatch(error, errorInfo) {
|
|
28
|
-
// TODO: 后期这里增加,isv异常上报。当前处理只是简单的console.log('错误信息')
|
|
29
|
-
// 打印错误信息,error错误信息,errorInfo错误堆栈
|
|
30
|
-
console.log('isv模块渲染异常ErrorBoundary==========error: ', error.toString())
|
|
31
|
-
console.log('isv模块渲染异常ErrorBoundary==========errorInfo: ', errorInfo.componentStack)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
render() {
|
|
35
|
-
if (this.state.hasError) {
|
|
36
|
-
// 可以在这里自定义出错降级后的 UI 并渲染
|
|
37
|
-
// 对于isv模块,出错后隐藏楼层
|
|
38
|
-
return null
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return this.props.children
|
|
42
|
-
}
|
|
43
|
-
}
|