Introduce Dialog abstraction
Summary: Introduce convenience abstractions to make it easier to manage dialogs imperatively, by promisyfying common dialog abstractions. Reviewed By: jknoxville, nikoant Differential Revision: D29790462 fbshipit-source-id: c092c15cf569ec353b9c1042f25cd67e6c76db01
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9c4deb3501
commit
f74029699f
@@ -16,13 +16,12 @@ import {render, unmountComponentAtNode} from 'react-dom';
|
||||
*/
|
||||
export function renderReactRoot(
|
||||
handler: (unmount: () => void) => React.ReactElement,
|
||||
): void {
|
||||
): () => void {
|
||||
const div = document.body.appendChild(document.createElement('div'));
|
||||
render(
|
||||
handler(() => {
|
||||
unmountComponentAtNode(div);
|
||||
div.remove();
|
||||
}),
|
||||
div,
|
||||
);
|
||||
const unmount = () => {
|
||||
unmountComponentAtNode(div);
|
||||
div.remove();
|
||||
};
|
||||
render(handler(unmount), div);
|
||||
return unmount;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user