diff --git a/src/pages/index.js b/src/pages/index.js index ddcf724..3414532 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -83,7 +83,7 @@ function fetchLeaderboard() { resolve(res) }) }) - }) + }, { staleTime: Infinity }) return data || [] } @@ -190,21 +190,27 @@ const NewsEntryContainer = ({ onTitleClick, }) => { const [error, setError] = useState(false) - if (!newsEntryData && !error) { - fetchEntry(postKey) - .then((res) => { - const { success, entry, msg } = res - if (success) { - setNews({ [postKey]: entry, ...news }) - } else { - alert(msg) + + useEffect(() => { + if (!newsEntryData && !error) { + fetchEntry(postKey) + .then((res) => { + const { success, entry, msg } = res + if (success) { + setNews({ [postKey]: entry, ...news }) + } else { + alert(msg) + setError(true) + } + }) + .catch((e) => { + console.error(e) setError(true) - } - }) - .catch((e) => { - console.error(e) - setError(true) - }) + }) + } + }, []) + + if (!newsEntryData) { return } diff --git a/src/pages/script.js b/src/pages/script.js index d5f8f40..962ca09 100644 --- a/src/pages/script.js +++ b/src/pages/script.js @@ -9,7 +9,7 @@ import ExternalLinkIcon from '../components/externalLinkIcon' import styles from './script.module.css' -function fetchSurouter.pathnamepportedSites() { +function fetchSupportedSites() { return new Promise((resolve) => { fetch(`${constants.apiUrl}supportedSites`, { credentials: 'include',