import React, { useState } from "react"; import { NavLink, useHistory } from "react-router-dom"; import { ethers } from "ethers"; import Logo from "./Logo"; import Timestamp from "./components/Timestamp"; import { useLatestBlock } from "./useLatestBlock"; const Home: React.FC = () => { const [search, setSearch] = useState(); const [canSubmit, setCanSubmit] = useState(false); const history = useHistory(); const handleChange: React.ChangeEventHandler = (e) => { setCanSubmit(e.target.value.trim().length > 0); setSearch(e.target.value.trim()); }; const handleSubmit: React.FormEventHandler = (e) => { e.preventDefault(); if (!canSubmit) { return; } history.push(`/search?q=${search}`); }; const latestBlock = useLatestBlock(); document.title = "Home | Otterscan"; return (
{latestBlock && (
Latest block: {ethers.utils.commify(latestBlock.number)}
)}
); }; export default React.memo(Home);