import React, { Component } from 'react' import Link from 'next/link' import { dispatch } from '@rematch/core' import { initStore } from '../shared/store' import withRematch from '../shared/utils/withRematch' import Header from '../shared/components/header' import CounterDisplay from '../shared/components/counter-display' class Github extends Component { static async getInitialProps ({ isServer, initialState }) { if (isServer) { await dispatch.github.fetchUsers() } return {} } render () { return (

Github users

Server rendered github user list. You can also reload the users from the api by clicking the Get users button below.

{this.props.isLoading ?

Loading ...

: null}

{this.props.userList.map(user => (
Username - {user.login}
))}
) } } const mapState = state => ({ userList: state.github.users, isLoading: state.github.isLoading }) const mapDispatch = ({ github: { fetchUsers } }) => ({ fetchUsers: () => fetchUsers() }) export default withRematch(initStore, mapState, mapDispatch)(Github)