React client app #5
@ -1,9 +1,8 @@
|
|||||||
import React, { useEffect } from "react";
|
import React from "react";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [imageSrc, setImageSrc] = React.useState("");
|
const [imageSrc, setImageSrc] = React.useState("");
|
||||||
const [displayOutput, setDisplayOutput] = React.useState(false);
|
|
||||||
const fileInput = React.useRef<HTMLInputElement>(null);
|
const fileInput = React.useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const handleClick = async () => {
|
const handleClick = async () => {
|
||||||
@ -12,7 +11,6 @@ function App() {
|
|||||||
}
|
}
|
||||||
const workerProxy: any = await wasmWorker("main.wasm");
|
const workerProxy: any = await wasmWorker("main.wasm");
|
||||||
|
|
||||||
setDisplayOutput(false);
|
|
||||||
setImageSrc("");
|
setImageSrc("");
|
||||||
|
|
||||||
// Check if a file was selected
|
// Check if a file was selected
|
||||||
@ -28,7 +26,6 @@ function App() {
|
|||||||
const ditheredImage = await workerProxy.DitherNord(imageData);
|
const ditheredImage = await workerProxy.DitherNord(imageData);
|
||||||
const outputValue = `data:image/png;base64,${ditheredImage}`;
|
const outputValue = `data:image/png;base64,${ditheredImage}`;
|
||||||
setImageSrc(outputValue);
|
setImageSrc(outputValue);
|
||||||
setDisplayOutput(true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -50,7 +47,7 @@ function App() {
|
|||||||
id="output"
|
id="output"
|
||||||
alt="dithering output"
|
alt="dithering output"
|
||||||
src={imageSrc}
|
src={imageSrc}
|
||||||
style={{ display: displayOutput ? "block" : "none" }}
|
style={{ display: imageSrc !== "" ? "block" : "none" }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user