// TODO: css remove unnecesarry stuff // TODO: fetch only once import React, { useState, useEffect } from 'react' import fetch from 'unfetch' import LoadingIndicator from '../components/LoadingIndicator' import links from '../data/links.json' import constants from '../constants.json' export default function Index (props) { const [motd, setMotd] = useState('loading...') const [news, setNews] = useState(null) useEffect(() => { console.info('Fetching news.json') fetch(`${constants.apiUrl}news.json`) // eslint-disable-line .then((resp) => { return resp.json() }) .then((data) => { setNews(data) }) }, []) useEffect(() => { console.info('Fetching data') fetch(`${constants.apiUrl}motd`) .then((resp) => { return resp.text() }) .then((data) => { setMotd(data) }) }, []) const renderNews = () => { if (news) { let questions = Object.keys(news).map((key, i) => { let q = news[key] return (