diff --git a/CHANGELOG.md b/CHANGELOG.md index bffc742f..baecec7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.49 (2023-05-19) +- **core**: 解决当组件被销毁,业务若异步(定时器)调用setState修改状态,可能出现路径错误问题。 + ## 0.0.48 (2023-05-18) - **core**: 解决style中属性WebkitLineClamp值被转换成字符串问题 @@ -19,12 +22,12 @@ - **core**: 增加jsx-dev-runtime文件,给vite使用 ## 0.0.40 (2023-03-08) -- **core**: #103 使用Memo、React.forwardRef包装组件后,defaultProps失效 +- **core**: #103 使用Memo、forwardRef包装组件后,defaultProps失效 - **core**: #104 --max-segment-num的style无法使用 - **core**: 状态管理器的优化 ## 0.0.39 (2023-02-21) -- **core**: #102 使用eview-react组件Dialog时,关闭组件horizon报错,且无法再打开弹框 +- **core**: #102 使用eview组件Dialog时,关闭组件horizon报错,且无法再打开弹框 ## 0.0.38 (2023-02-01) - **core**: 增加flushSync接口 @@ -58,7 +61,7 @@ - **core**: fix 修改IE上报Symbol错误的问题 ## 0.0.23 (2022-09-23) -- **core**: #86 兼容ReactIs API +- **core**: #86 兼容Is API ## 0.0.22 (2022-09-22) - **core**: #83 #75 #72 input支持受控 diff --git a/libs/horizon/package.json b/libs/horizon/package.json index 71fad88d..35b506ef 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.48", + "version": "0.0.49", "homepage": "", "bugs": "", "main": "index.js", diff --git a/libs/horizon/src/dom/DOMOperator.ts b/libs/horizon/src/dom/DOMOperator.ts index a7abe22d..f83893e5 100644 --- a/libs/horizon/src/dom/DOMOperator.ts +++ b/libs/horizon/src/dom/DOMOperator.ts @@ -141,7 +141,7 @@ export function newTextDom(text: string, processing: VNode): Text { return textNode; } -// 提交vNode的类型为Component或者Text的更新 +// 提交vNode的类型为DomComponent或者DomText的更新 export function submitDomUpdate(tag: string, vNode: VNode) { const newProps = vNode.props; const element: Element | null = vNode.realNode; diff --git a/libs/horizon/src/dom/validators/ValidateProps.ts b/libs/horizon/src/dom/validators/ValidateProps.ts index d6629b29..f025ce63 100644 --- a/libs/horizon/src/dom/validators/ValidateProps.ts +++ b/libs/horizon/src/dom/validators/ValidateProps.ts @@ -98,7 +98,7 @@ export function validateProps(type, props) { return; } - // 非内置的变迁 + // 非内置的元素 if (!isNativeElement(type, props)) { return; } diff --git a/libs/horizon/src/renderer/TreeBuilder.ts b/libs/horizon/src/renderer/TreeBuilder.ts index eb20b0ef..9798bb8a 100644 --- a/libs/horizon/src/renderer/TreeBuilder.ts +++ b/libs/horizon/src/renderer/TreeBuilder.ts @@ -179,6 +179,11 @@ function isEqualByIndex(idx: number, pathArrays: string[][]) { function getChildByIndex(vNode: VNode, idx: number) { let node = vNode.child; for (let i = 0; i < idx; i++) { + // 场景:当组件被销毁,业务若异步(定时器)调用setState修改状态,可能出现路径错误,此处进行保护。 + if (node == null) { + return null; + } + node = node.next; } return node; diff --git a/libs/horizon/src/renderer/components/BaseClassComponent.ts b/libs/horizon/src/renderer/components/BaseClassComponent.ts index de4ff351..70b09ee4 100644 --- a/libs/horizon/src/renderer/components/BaseClassComponent.ts +++ b/libs/horizon/src/renderer/components/BaseClassComponent.ts @@ -33,7 +33,7 @@ class Component
{ setState(state: S, callback?: Callback) { if (isDev) { - console.error('Cant not call `this.setState` in the constructor of class component, it will do nothing'); + console.error('Can not call `this.setState` in the constructor of class component, it will do nothing'); } } }