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();
},
};
};
漫思