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
{ | |
"products" : [ | |
{ | |
"id" : 1, | |
"name" : "Crib One", | |
"desc" : "Cribs of the first kind. It's like a heavenly cloud to make your babies sleep sound.", | |
"price" : 45.99, | |
"thumbnail": "./assets/crib1.jpg", | |
"images": ["./assets/crib2.jpg", "./assets/crib3.jpg", "./assets/crib4.jpg", "./assets/crib5.jpg"] | |
}, |
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
const path = require('path'); | |
const webpack = require('webpack'); | |
const nodeExternals = require('webpack-node-externals'); | |
const common = { | |
rules: [{ test: /\.(js)$/, use: 'babel-loader' }], | |
}; | |
const clientConfig = { | |
entry: './src/client/index.js', |
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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"env", | |
{ | |
"targets": { | |
"browsers": ["last 2 versions"], | |
"node": "8.11.3" | |
} | |
} |
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, { Component } from 'react'; | |
import { Switch, Navlink, Route } from 'react-router-dom'; | |
import Navbar from './components/Navbar'; | |
import NoMatch from './components/NoMatch'; | |
import UniversalDataloader from './components/UniversalDataloader'; | |
import routes from './routes'; | |
class App extends Component { |
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'; | |
import { Link } from 'react-router-dom'; | |
import Loading from './Loading'; | |
const Home = ({ loading, data }) => ( | |
<div className="home container"> | |
<Helmet> | |
<title>FavMovies - Home</title> |
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 { Component } from 'react'; | |
class UniversalDataloader extends Component { | |
constructor(props) { | |
super(props); | |
let data; | |
if (__isBrowser__ && window.__SERIALIZED_DATA__) { | |
data = window.__SERIALIZED_DATA__; | |
delete window.__SERIALIZED_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 axios from 'axios'; | |
const baseUri = 'http://localhost:3002'; | |
export const fetchAllMovies = () => | |
axios | |
.get(`${baseUri}/movies`) | |
.then(({ data }) => data) | |
.catch(e => { | |
console.log(e); |
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 Home from './components/Home'; | |
import Movie from './components/Movie'; | |
import { fetchAllMovies, fetchMovieById } from './apiCalls'; | |
const routes = [ | |
{ | |
path: '/', | |
exact: true, | |
C: Home, |
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 { hydrate } from 'react-dom'; | |
import { BrowserRouter } from 'react-router-dom'; | |
import App from '../shared/App'; | |
hydrate( | |
<BrowserRouter> | |
<App /> | |
</BrowserRouter>, |
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 express from 'express'; | |
import cors from 'cors'; | |
import React from 'react'; | |
import { Helmet } from 'react-helmet'; | |
import { renderToString } from 'react-dom/server'; | |
import { matchPath, StaticRouter } from 'react-router-dom'; | |
import App from '../shared/App'; | |
import routes from '../shared/routes'; |
OlderNewer