This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Link, Switch, Route } from "react-router-dom"; | |
import Home from "./Home"; | |
import About from "./About"; | |
import Contact from "./Contact"; | |
export default class Layout extends React.Component { | |
/* ... */ | |
render() { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Link, Switch, Route } from "react-router-dom"; | |
import Home from "./Home"; | |
import About from "./About"; | |
import Contact from "./Contact"; | |
export default class Layout extends React.Component { | |
/* ... */ | |
render() { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactDOM from "react-dom"; | |
import Layout from "./components/Layout"; | |
const app = document.getElementById( "app" ); | |
ReactDOM.hydrate( <Layout />, app ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
import Helmet from "react-helmet"; | |
/* ... */ | |
app.get( "/*", ( req, res ) => { | |
/* ... */ | |
const jsx = ( | |
<ReduxProvider store={ store }> | |
<StaticRouter context={ context } location={ req.url }> | |
<Layout /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Helmet from "react-helmet"; | |
const Contact = () => ( | |
<div> | |
<h2>This is the contact page</h2> | |
<Helmet> | |
<title>Contact Page</title> | |
<meta name="description" content="This is a proof of concept for React SSR" /> | |
</Helmet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
import { StaticRouter, matchPath } from "react-router-dom"; | |
import routes from "./routes"; | |
/* ... */ | |
app.get( "/*", ( req, res ) => { | |
/* ... */ | |
const dataRequirements = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
import { fetchData } from "../store"; | |
class Home extends React.Component { | |
/* ... */ | |
render( ) { | |
const { circuits } = this.props; | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default [ | |
{ | |
path: "/", | |
component: Home, | |
exact: true, | |
}, | |
{ | |
path: "/about", | |
component: About, | |
exact: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import { BrowserRouter as Router } from "react-router-dom"; | |
import { Provider as ReduxProvider } from "react-redux"; | |
import Layout from "./components/Layout"; | |
import createStore from "./store"; | |
const store = createStore( window.REDUX_DATA ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
import { Provider as ReduxProvider } from "react-redux"; | |
/* ... */ | |
app.get( "/*", ( req, res ) => { | |
const context = { }; | |
const store = createStore( ); | |
store.dispatch( initializeSession( ) ); |
NewerOlder