import { useSelector } from "react-redux"; import { useRematchDispatch } from "../shared/utils"; import { initializeStore } from "../shared/store"; import CounterDisplay from "../shared/components/counter-display"; import Header from "../shared/components/header"; const Github = (props) => { const github = useSelector((state) => state.github); const { users, isLoading } = github; const { fetchUsers } = useRematchDispatch((dispatch) => ({ fetchUsers: dispatch.github.fetchUsers, })); const { usersList } = props; return (

Github users

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

Users passed as property from getStaticProps

{usersList.map((user) => (
Username - {user.login}
))} {isLoading ?

Loading ...

: null}

{users.length === 0 ? null :

Users fetched from async function

} {users.map((user) => (
Username - {user.login}
))}
); }; export async function getStaticProps() { const store = initializeStore(); const usersList = await store.dispatch.github.fetchUsers(); return { props: { usersList, }, }; } export default Github;