Fix react warnings

This commit is contained in:
Tyler Hallada 2022-03-19 15:38:33 -04:00
parent 7df5cbb324
commit 79631cbc05
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import { format } from "date-fns"; import { format } from "date-fns";
import Head from "next/head"; import Head from "next/head";
import React from "react"; import React, { useEffect } from "react";
import useSWRImmutable from "swr/immutable"; import useSWRImmutable from "swr/immutable";
import CellList from "./CellList"; import CellList from "./CellList";
@ -50,6 +50,10 @@ const ModData: React.FC<Props> = ({
(_) => jsonFetcher<Mod>(_) (_) => jsonFetcher<Mod>(_)
); );
useEffect(() => {
if (data) setSelectedCells(data.cells);
}, [data, setSelectedCells]);
if (error && error.status === 404) { if (error && error.status === 404) {
return <div>Mod could not be found.</div>; return <div>Mod could not be found.</div>;
} else if (error) { } else if (error) {
@ -66,8 +70,6 @@ const ModData: React.FC<Props> = ({
const unique_downloads = modCounts ? modCounts[1] : 0; const unique_downloads = modCounts ? modCounts[1] : 0;
const views = modCounts ? modCounts[2] : 0; const views = modCounts ? modCounts[2] : 0;
setSelectedCells(data.cells);
if (selectedMod && data) { if (selectedMod && data) {
return ( return (
<> <>

View File

@ -58,7 +58,8 @@ const PluginsList: React.FC<Props> = ({ selectedCell }) => {
disabled={ disabled={
excludedPlugins.includes(plugin.filename) || !!plugin.parseError excludedPlugins.includes(plugin.filename) || !!plugin.parseError
} }
checked={plugin.enabled} checked={plugin.enabled ?? false}
value={plugin.enabled ? "on" : "off"}
onChange={() => dispatch(togglePlugin(plugin.filename))} onChange={() => dispatch(togglePlugin(plugin.filename))}
/> />
<label htmlFor={plugin.filename} className={styles["plugin-label"]}> <label htmlFor={plugin.filename} className={styles["plugin-label"]}>