react/shells/dev/app/index.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-01-23 03:04:37 +08:00
/** @flow */
// This test harness mounts each test app as a separate root to test multi-root applications.
2019-01-23 03:04:37 +08:00
import { createElement } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import DeeplyNestedComponents from './DeeplyNestedComponents';
import EditableProps from './EditableProps';
import ElementTypes from './ElementTypes';
import InspectableElements from './InspectableElements';
import InteractionTracing from './InteractionTracing';
import ToDoList from './ToDoList';
2019-01-23 03:04:37 +08:00
import './styles.css';
const containers = [];
2019-01-23 03:04:37 +08:00
function mountHelper(App) {
const container = document.createElement('div');
((document.body: any): HTMLBodyElement).appendChild(container);
containers.push(container);
render(createElement(App), container);
}
function mountTestApp() {
mountHelper(ToDoList);
mountHelper(InteractionTracing);
mountHelper(InspectableElements);
mountHelper(ElementTypes);
mountHelper(EditableProps);
mountHelper(DeeplyNestedComponents);
}
function unmountTestApp() {
containers.forEach(container => unmountComponentAtNode(container));
}
mountTestApp();
window.parent.mountTestApp = mountTestApp;
window.parent.unmountTestApp = unmountTestApp;