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

[Feature Request] renderClient 能否返回 app 实例?手动 render 时想要获取到 app 实例,因为需求是在指定时机手动销毁 app 实例 #12097

Closed
guoqiwen8 opened this issue Jan 25, 2024 · 1 comment

Comments

@guoqiwen8
Copy link

Background

项目需求是在指定时机渲染以及手动销毁 app 实例,所以希望可以在手动 render 后先能获取到 app 实例,这样在 React 18 中才能使用 root.unmount()方法销毁

Proposal

希望能对在packages/renderer-react/src/browser.tsx中的renderClient方法中的
if (ReactDOM.createRoot) { root = ReactDOM.createRoot(rootElement); root.render(); return; }
修改为
if (ReactDOM.createRoot) { root = ReactDOM.createRoot(rootElement); root.render(); return root; }
这样我就可以在app.tsx文件中的 render 方法里 拿到 root了,像这样:
export const render = (oldRender) => { const root = oldRender(); };

Additional context

经尝试,现在的oldRender()返回的是undefined,让我无法使用root.unmount()进行app销毁

@fz6m
Copy link
Member

fz6m commented Jan 25, 2024

See #12096

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

No branches or pull requests

2 participants