Skip to content

Instantly share code, notes, and snippets.

const express = require('express');
const app = express();
// Application
app.get('/', function(req, res) {
if (process.env.NODE_ENV === 'development') {
for (var key in require.cache) {
delete require.cache[key];
}
}
@h9h
h9h / server.js
Created June 19, 2019 06:38 — forked from ryanoglesby08/server.js
A node.js SPA server that serves static files and an index.html file for all other routes.
/*
Incredibly simple Node.js and Express application server for serving static assets.
Given as an example from the React Router documentation (along with examples
using nginx and Apache):
- https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md#browserhistory
*/
const express = require('express');
const path = require('path');

Preparation

cd slides
git clone https://github.com/hakimel/reveal.js.git
ren reveal.js name-of-presentation
cd name-of-presentation
del package-lock.json
yarn install
yarn start
@h9h
h9h / blog.md
Last active November 21, 2018 20:46
Landing Page
@h9h
h9h / Readme.md
Last active November 21, 2018 16:32
React + Webpack 4 + Babel 7 (2018)

Setup Source-directory src

Create src/index.js containing something like:

import ReactDOM from 'react-dom'
import App from './App'
const app = document.getElementById('app')
ReactDOM.render(<App />, app)
@h9h
h9h / react-lifecycle-cheatsheet.md
Created December 29, 2017 13:45 — forked from bvaughn/react-lifecycle-cheatsheet.md
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props
@h9h
h9h / on-jsx.markdown
Created March 12, 2016 19:00 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'