Skip to content

Instantly share code, notes, and snippets.

Kelly kellyrmilligan

Block or report user

Report or block kellyrmilligan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kellyrmilligan
kellyrmilligan / start.js
Created Dec 13, 2017
start.js - adjusted
View start.js
'use strict';
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
@kellyrmilligan
kellyrmilligan / webpackDevServer.config.js
Created Dec 13, 2017
webpackDevServer.config.js - adjusted
View webpackDevServer.config.js
'use strict';
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const path = require('path');
const config = require('./webpack.config.dev');
const paths = require('./paths');
const express = require('express');
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
@kellyrmilligan
kellyrmilligan / webpack.config.dev.js
Created Dec 13, 2017
webpack.config.dev.js - adjusted
View webpack.config.dev.js
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
View withreactcomponentclickhandler
const List = ({ items, onClick }) => (
<ul>
{items.map(item => (
<ClickHandler key={item.id} data={item} onClick={onClick}>
{(handleClick) => (
<li onClick={handleClick}>
{item.text}
</li>
)}
</ClickHandler>
View exampleinlinefunctinreactclickhandler
const List = ({ items, onClick }) => (
<ul>
{items.map(item => (
<li onClick={() => onClick(item)}>
{item.text}
</li>
))}
</ul>
)
View loopingthroughlistsreact
const List = ({ items, onClick }) => (
<ul>
{items.map(item => (
<li>
{item.text}
</li>
))}
</ul>
)
@kellyrmilligan
kellyrmilligan / multiple calls from a loop with caching
Last active Aug 22, 2017
multiple calls with client side caching
View multiple calls from a loop with caching
import CacheClientPromise from 'cache-client-promise'
const myCache = new CacheClientPromise();
[{
id: 1234,
title: 'test',
view: 'two-column'
},
{
@kellyrmilligan
kellyrmilligan / multiple calls from a loop
Created Aug 22, 2017
multiple calls from a result - no caching
View multiple calls from a loop
[{
id: 1234,
title: 'test',
view: 'two-column'
},
{
id: 1234,
title: 'test',
view: 'image-only'
}]
View flow type example
// @flow
import React from 'react'
import classnames from 'classnames'
import type { ButtonT } from './ButtonT'
const Button = ({ className, type = 'button', text, tabIndex, onClick = () => {}, disabled = false }: ButtonT) => (
<button
className={classnames('button', className)}
type={type}
@kellyrmilligan
kellyrmilligan / App-example.js
Created Jun 8, 2017
sending a notification when service worker is updated in top level component
View App-example.js
componentWillReceiveProps (nextProps) {
// see if new content was found by the service worker
if (nextProps.serviceWorker.serviceWorkerUpdated) {
this.setState({
notifications: this.state.notifications.concat({
'The app has been updated! Hooray! Refresh your browser to enjoy the latest and greatest',
'some unique key',
action: 'Dismiss',
dismissAfter: 4000,
onClick: this.removeNotification
You can’t perform that action at this time.