Dynamic Imports

This commit is contained in:
Felix Kaspar
2024-01-28 21:22:59 +01:00
parent fbc921a077
commit 50ab159abe
5 changed files with 29 additions and 10 deletions

View File

@@ -1,18 +1,14 @@
import { Link } from "react-router-dom";
import { listOperatorNames } from "@stirling-pdf/shared-operations/src/workflow/getOperatorByName"
import { Impose } from "@stirling-pdf/shared-operations/src/functions/impose"
import { BaseSyntheticEvent } from "react";
function Dynamic() {
console.log(listOperatorNames());
const operators = listOperatorNames();
const operators = ["impose"]; // TODO: Make this dynamic
function selectionChanged(s: BaseSyntheticEvent) {
const selectedValue = s.target.value;
if(selectedValue == "none") return;
const LoadedOperator = import(`../shared-operations/src/functions/${selectedValue}`);
const LoadedOperator = import(`@stirling-pdf/shared-operations/src/functions/${selectedValue}`);
LoadedOperator.then(console.log);
}
@@ -28,9 +24,9 @@ function Dynamic() {
<br />
<select id="pdfOptions" onChange={selectionChanged}>
<option value="none">none</option>
{operators.map((operator, i) => {
{ operators.map((operator, i) => {
return (<option value={operator}>{operator}</option>)
})}
}) }
</select>
<button id="loadButton">Load</button>
<br />