Farmbot-Web-App/frontend/password_reset/on_init.ts

19 lines
603 B
TypeScript
Raw Normal View History

2019-10-30 14:14:31 -06:00
import { Callback } from "i18next";
2019-02-04 09:31:52 -07:00
import _React, { createElement } from "react";
2019-01-31 10:24:10 -07:00
import { render } from "react-dom";
import { PasswordReset } from "./password_reset";
import { bail } from "../util";
export const MISSING_DIV = "Add a div with id `root` to the page first.";
2019-10-30 14:14:31 -06:00
export const onInit: Callback = async () => {
const node = document.createElement("DIV");
node.id = "root";
document.body.appendChild(node);
2019-02-04 09:31:52 -07:00
const reactElem = createElement(PasswordReset, {});
const domElem = document.getElementById("root");
return (domElem) ? render(reactElem, domElem) : bail(MISSING_DIV);
};