import React, { Component } from "react"; import { render } from "react-dom"; import { Router, Link } from "@reach/router"; import "fomantic-ui-css/semantic.css"; import "./App.css"; import { Dropdown, Menu, Icon, Loader, Container } from "semantic-ui-react"; import Home from "./Home"; import Thread from "./Thread"; import Board from "./Board"; import NotFound from "./NotFound"; class App extends Component { constructor() { super(); this.state = { boardList: [], isLoaded: false }; } componentDidMount() { fetch("https://bienvenidoainternet.org/cgi/api/boards") .then(response => { return response.json(); }) .then(resource => { this.setState({ boardList: resource["boards"], isLoaded: true }); }) .catch(console.error); } render() { if (!this.state.isLoaded) { if (!this.state.isLoaded) { return ( Cargando ... ); } } const { boardList } = this.state; //const pathList = boardList.map(board => "/" + board.dir) return ( B.a.I Home {boardList.map(board => board.board_type === 1 ? ( /{board.dir}/ - {board.name} ) : null )} {boardList.map(board => board.board_type === 0 ? ( /{board.dir}/ - {board.name} ) : null )} ); } } render(, document.getElementById("root"));