有如下代码,请问在shell reload之后怎么重新 render 整个App, 这也写App内部的state都没有清掉,感觉App像是单例,望解答原理。
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
import Bridge from '../util/bridge';
export function initDevTools(shell: any) {
// initApp(shell);
// initStorage().then(() => {
initApp(shell);
shell.onReload(() => {
// if (app) {
// app.$el.classList.add('disconnected');
// app.$destroy();
// }
Bridge.instance.removeAllListeners();
initApp(shell);
});
// });
}
function initApp(shell: any) {
shell.connect((bridge: Bridge) => {
Bridge.instance = bridge;
ReactDOM.render(<App />, document.querySelector('#app'));
});
}
待解决
悬赏分:20
- 离问题结束还有
点赞 0反对 0举报 0
收藏 0
分享 1
