Skip to content

强烈建议增加销毁方法 #81

Open
@fgfg163

Description

@fgfg163

使用版本 1.1.4

hox使用 createModal 创建实例,但是没有销毁方法,在 modal 里使用副作用例如监听dom元素没有办法在最后销毁。

强烈建议增加一个销毁方法 destroy 以便手动触发 unmount

参考react-dom的销毁方法,

https://github.com/facebook/react/blob/784a725fe139b88c37f8b16d1d2225e88caf2612/packages/react-dom/src/client/ReactDOMLegacy.js#L361

https://github.com/facebook/react/blob/784a725fe139b88c37f8b16d1d2225e88caf2612/packages/react-dom/src/client/ReactDOMLegacy.js#L189

只需要在调用destroy方法时将 hox 内部的react root 清空,就可以卸载掉数据组件,触发unmount

// 第一个参数设置为null表示清空子组件
reconciler.updateContainer(null, container, null, null);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions