Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议增加一个销毁方法 #73

Open
fgfg163 opened this issue Jul 7, 2021 · 0 comments
Open

建议增加一个销毁方法 #73

fgfg163 opened this issue Jul 7, 2021 · 0 comments

Comments

@fgfg163
Copy link

fgfg163 commented Jul 7, 2021

使用版本 1.1.4

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

建议增加一个销毁方法以便触发 unmount

如果没有别的办法,可以考虑在 render (Executor 的时候多套一层根节点,销毁的时候把数据节点从根节点上移除就能触发 unmount

export function createModel<T, P>(hook: ModelHook<T, P>, hookArg?: P) {

export function createModel<T, P>(hook: ModelHook<T, P>, hookArg?: P) {
  const container = new Container(hook);
  render(
    <Executor
      onUpdate={val => {
        container.data = val;
        container.notify();
      }}
      hook={() => hook(hookArg)}
    />
  );
  // ......
}
@awmleer awmleer mentioned this issue May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant