alifd的dialog.show的源代码 ReactDOM.render

FusionDesign设计平台 - PC 官网
export const show = (config = {}) => {
const container = document.createElement('div');
const unmount = () => {
if (config.afterClose) {
config.afterClose();
}
ReactDOM.unmountComponentAtNode(container);
container.parentNode.removeChild(container);
};

document.body.appendChild(container);
let newContext = config.contextConfig;
if (!newContext) newContext = ConfigProvider.getContext();

let instance, myRef;

ReactDOM.render(
<ConfigProvider {...newContext}>
<ConfigModal
{...config}
afterClose={unmount}
ref={ref => {
myRef = ref;
}}
/>
</ConfigProvider>,
container,
function() {
instance = myRef;
}
);
return {
hide: () => {
const inc = instance && instance.getInstance();
inc && inc.close();
},
};
};

posted on 2022-06-26 17:44  漫思  阅读(24)  评论(0编辑  收藏  举报

导航