@salad-labs/loopz-typescript
Version:
The Official Loopz TypeScript SDK
28 lines • 1.01 kB
JavaScript
import React from "react";
import { createRoot } from "react-dom/client";
import { v4 as uuid } from "uuid";
import { LoopzAuth } from "../react/components/loopzauth";
export default class AuthAdapter {
constructor(authAdapterOptions) {
this._container = null;
this._root = null;
this._container = document.createElement("div");
this._container.id = uuid();
this._options = authAdapterOptions;
document.body.appendChild(this._container);
this._root = createRoot(this._container);
}
render() {
if (!this._root)
throw new Error("Root object must be initializated.");
this._root.render(React.createElement(LoopzAuth, Object.assign({}, this._options),
React.createElement(React.Fragment, null)));
}
cleanup() {
if (this._container && this._root) {
this._root.unmount();
document.body.removeChild(this._container);
}
}
}
//# sourceMappingURL=authadapter.js.map