diff --git a/components/ModData.tsx b/components/ModData.tsx index 32326a2..ea065a3 100644 --- a/components/ModData.tsx +++ b/components/ModData.tsx @@ -1,6 +1,6 @@ import { format } from "date-fns"; import Head from "next/head"; -import React from "react"; +import React, { useEffect } from "react"; import useSWRImmutable from "swr/immutable"; import CellList from "./CellList"; @@ -50,6 +50,10 @@ const ModData: React.FC = ({ (_) => jsonFetcher(_) ); + useEffect(() => { + if (data) setSelectedCells(data.cells); + }, [data, setSelectedCells]); + if (error && error.status === 404) { return
Mod could not be found.
; } else if (error) { @@ -66,8 +70,6 @@ const ModData: React.FC = ({ const unique_downloads = modCounts ? modCounts[1] : 0; const views = modCounts ? modCounts[2] : 0; - setSelectedCells(data.cells); - if (selectedMod && data) { return ( <> diff --git a/components/PluginsList.tsx b/components/PluginsList.tsx index 79ff84b..2ab3862 100644 --- a/components/PluginsList.tsx +++ b/components/PluginsList.tsx @@ -58,7 +58,8 @@ const PluginsList: React.FC = ({ selectedCell }) => { disabled={ excludedPlugins.includes(plugin.filename) || !!plugin.parseError } - checked={plugin.enabled} + checked={plugin.enabled ?? false} + value={plugin.enabled ? "on" : "off"} onChange={() => dispatch(togglePlugin(plugin.filename))} />