Optimize render in src/js/main/main.tsx
This commit is contained in:
parent
37e163aabd
commit
c36d7c5e12
1 changed files with 13 additions and 12 deletions
|
@ -7,33 +7,34 @@ import { Task } from "~/components/Task";
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const components = {
|
const components = {
|
||||||
"react-newtask": (
|
"react-newtask": () => (
|
||||||
<App>
|
<App>
|
||||||
<Task />
|
<Task />
|
||||||
</App>
|
</App>
|
||||||
),
|
),
|
||||||
"react-edittask": (
|
"react-edittask": () => (
|
||||||
<App>
|
<App>
|
||||||
<Task />
|
<Task />
|
||||||
</App>
|
</App>
|
||||||
),
|
),
|
||||||
"react-tasks": (
|
"react-tasks": () => (
|
||||||
<App>
|
<App>
|
||||||
<Tasks />
|
<Tasks />
|
||||||
</App>
|
</App>
|
||||||
),
|
),
|
||||||
"react-projects": (
|
"react-projects": () => (
|
||||||
<App>
|
<App>
|
||||||
<Projects />
|
<Projects />
|
||||||
</App>
|
</App>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Object
|
const ents = Object.entries(components);
|
||||||
.entries(components)
|
for (let i = 0; i < ents.length; i++) {
|
||||||
.forEach(([name, jsx]) => {
|
const [name, getJSX] = ents[i];
|
||||||
const root = document.querySelector(`.${name}`);
|
const root = document.querySelector(`.${name}`);
|
||||||
if (root) {
|
if (root) {
|
||||||
ReactDOM.createRoot(root).render(jsx);
|
ReactDOM.createRoot(root).render(getJSX());
|
||||||
}
|
break;
|
||||||
});
|
}
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue