# ssr-react-koa **Repository Path**: peigenzi/ssr-react-koa ## Basic Information - **Project Name**: ssr-react-koa - **Description**: No description available - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-04-17 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ssr-react-koa ```js import React, { Component } from "react"; class Grid extends Component { constructor(props) { super(props); let repos; if (__isBrowser__) { repos = window.__INITIAL_DATA__; delete window.__INITIAL_DATA__; } else { repos = this.props.staticContext.data; } this.state = { repos, loading: repos ? false : true, }; this.fetchRepos = this.fetchRepos.bind(this); } componentDidMount() { if (!this.state.repos) { this.fetchRepos(this.props.match.params.id); } } componentDidUpdate(prevProps, prevState) { if (prevProps.match.params.id !== this.props.match.params.id) { this.fetchRepos(this.props.match.params.id); } } fetchRepos(lang) { this.setState(() => ({ loading: true, })); this.props.fetchInitialData(lang).then((repos) => this.setState(() => ({ repos, loading: false, })) ); } render() { const { loading, repos } = this.state; if (loading === true) { return

LOADING

; } return ( ); } } export default Grid; ```