// @flow import React from "react"; import {Link} from "react-router-dom"; export default class Pagination extends React.Component { props: { total: number; current: number; location: { pathname: string; search: string; hash: string; }; } link(page: number) { const queries = this.props.location.search.substring(1).split("&") .filter(query => query && !query.startsWith("page=")); return { pathname: this.props.location.pathname, search: `?${queries.concat([`page=${page}`]).join("&")}`, hash: this.props.location.hash, }; } renderPrev() { return ( this.props.current === 1 ?
  • :
  • ); } renderNext() { return ( this.props.current === this.props.total ?
  • :
  • ); } render() { const pages = []; for (let i = 1; i <= this.props.total; i++) { pages.push(i); } return ( ); } }