ghost-keychain/packages/extension-ui/src/createView.tsx
Jaco 6bfddb09e8
Use .js imports in src (#1224)
* Use .js imports in src

* Bump dev

* Add WP extension aliases
2023-03-09 11:04:13 +02:00

29 lines
734 B
TypeScript

// Copyright 2019-2023 @polkadot/extension-ui authors & contributors
// SPDX-License-Identifier: Apache-2.0
import './i18n/i18n.js';
import React, { Suspense } from 'react';
import { createRoot } from 'react-dom/client';
import { HashRouter } from 'react-router-dom';
import { View } from './components/index.js';
export default function createView (Entry: React.ComponentType, rootId = 'root'): void {
const rootElement = document.getElementById(rootId);
if (!rootElement) {
throw new Error(`Unable to find element with id '${rootId}'`);
}
createRoot(rootElement).render(
<Suspense fallback='...'>
<View>
<HashRouter>
<Entry />
</HashRouter>
</View>
</Suspense>
);
}