import { useEffect, useCallback, useState } from "react"; import type { NextPage } from "next"; import Head from "next/head"; import "mapbox-gl/dist/mapbox-gl.css"; import Map from "../components/Map"; import { useAppDispatch } from "../lib/hooks"; import { setPluginsTxtAndApplyLoadOrder } from "../slices/pluginsTxt"; import { WorkerPool, WorkerPoolContext } from "../lib/WorkerPool"; const Home: NextPage = () => { const [workerPool, setWorkerPool] = useState(null); const dispatch = useAppDispatch(); const createWorkerPool = useCallback(async () => { setWorkerPool( await new WorkerPool().init(window.navigator.hardwareConcurrency) ); }, []); useEffect(() => { return () => { if (workerPool) { workerPool.terminateAll(); } }; // eslint-disable-next-line react-hooks/exhaustive-deps }, [dispatch]); useEffect(() => { createWorkerPool(); }, [createWorkerPool]); return ( <> Modmapper
{ evt.preventDefault(); }} onDrop={async (evt) => { evt.preventDefault(); if (evt.dataTransfer.items && evt.dataTransfer.items.length > 0) { const file = evt.dataTransfer.items[0].getAsFile(); if (file) { dispatch(setPluginsTxtAndApplyLoadOrder(await file.text())); } } }} >
); }; export default Home;