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 h = (type, props, ...children) => | |
({ type, props, children }); | |
/* -------------------- */ | |
/* Creating */ | |
/* -------------------- */ | |
/* using h */ | |
const App = (props) => h('div', null, 'hello'); |
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 cn from 'classnames'; | |
import './accordion.css'; | |
class List extends React.Component { | |
state = { | |
open: 0, | |
} | |
toggleSection = (index) => () => { |
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 assetsManifest from '../../build/client/assetsManifest.json'; | |
//read the styles into an assets object during server startup | |
export const assets = Object.keys(assetsManifest) | |
.reduce((o, entry) => ({ | |
...o, | |
[entry]: { | |
...assetsManifest[entry], | |
styles: assetsManifest[entry].css | |
? fs.readFileSync(`build/client/css/${assetsManifest[entry].css.split('/').pop()}`, 'utf8') : undefined, | |
}, |
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 assetsManifest from '../../build/client/assetsManifest.json'; | |
lateChunk(app, head, initialState, route) { | |
return ` | |
<style>${assets.main.styles}</style> | |
// inline the current route's css and assign an id to it | |
${!assets[route.name] ? '' : `<style id="${route.name}.css">${assets[route.name].styles}</style>`} | |
</head> | |
<body> | |
<div id="root">${app}</div> |
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, { PropTypes } from 'react'; | |
import cn from 'classnames'; | |
const Text = ({ | |
className, | |
tag, | |
preview, | |
previewStyle, | |
children, | |
...props |
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
// register the service worker after the onload event to prevent | |
// bandwidth resource contention during the main and vendor js downloads | |
export const scripts = { | |
serviceWorker: | |
`"serviceWorker" in window.navigator && window.addEventListener("load", function() { | |
window.navigator.serviceWorker.register("/serviceWorker.js") | |
.then(function(r) { | |
console.log("ServiceWorker registration successful with scope: ", r.scope) | |
}).catch(function(e) { | |
console.error("ServiceWorker registration failed: ", 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
{ | |
"name": "Treebo Hotels", | |
"short_name": "Treebo", | |
"description": "India's Top Rated Budget Hotel Chain", | |
"theme_color": "#ffffff", | |
"background_color": "#ffffff", | |
"start_url": "/", | |
"display": "standalone", | |
"orientation": "portrait", | |
"icons": [{ |
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
resolve: { | |
alias: { | |
react: 'preact-compat', | |
'react-dom': 'preact-compat', | |
}, | |
}, |
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
earlyChunk(route) { | |
return ` | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<link rel="stylesheet" href="${assets.main.css}"> | |
<link rel="preload" as="script" href="${assets.webpackManifest.js}"> | |
<link rel="preload" as="script" href="${assets.vendor.js}"> | |
<link rel="preload" as="script" href="${assets.main.js}"> | |
${!assets[route.name] ? '' : `<link rel="preload" as="script" href="${assets[route.name].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
//add the webpackManifest and vendor script files to your html | |
<body> | |
<div id="root">${app}</div> | |
<script>window.__INITIAL_STATE__ = ${JSON.stringify(initialState)}</script> | |
<script src="${assets.webpackManifest.js}"></script> | |
<script src="${assets.vendor.js}"></script> | |
<script src="${assets.main.js}"></script> | |
</body> |
NewerOlder