Skip to content

Instantly share code, notes, and snippets.

View samMeow's full-sized avatar

samuel kwok samMeow

View GitHub Profile
import React from 'react';
import ReactDOM from 'react-dom';
let shouldRender = false;
const Children = () => {
if (shouldRender) {
return (<div>Hello world</div>);
}
throw new Promise((resolve) => {
setTimeout(() => {
const elementExistPromise = (selectorFunc, parent = document.body) => {
const exists = selectorFunc(parent);
if (exists && exists.length !== 0) {
return Promise.resolve(exists);
}
return new Promise(resolve => {
const mu = new MutationObserver((list, me) => {
const record = list.find(({ target }) => {
const x = selectorFunc(target);
return x && x.length !== 0;