import React, { Component } from 'react' import Link from 'next/link' import { connect } from 'react-redux' import { checkServer } from '../shared/utils' import CounterDisplay from '../shared/components/counter-display' import Header from '../shared/components/header' class Github extends Component { static async getInitialProps (ctx) { const store = ctx.reduxStore // Pre-populate users only on the server-side if (checkServer()) { await store.dispatch.github.fetchUsers() } return {} } render () { const { isLoading, fetchUsers, userList } = this.props return (
Server rendered github user list. You can also reload the users from the api by clicking the Get users button below.
{isLoading ?Loading ...
: null}{userList.map(user => ( ))}