Here's a very bare bones approach.
First, create a webpack.config.js
file. This is what goes in:
const config = {
entry: 'src/index.js', // path to your app entry point
output: {
// Implementation | |
const toQueryString = params => Object.entries(params) | |
.map((param) => param.join('=')) | |
.join('&'); | |
// Example usage | |
const qs = toQueryString({ apiKey: 'secret', page: 2 }); | |
qs === 'apiKey=secret&page=2' |
import React, { Component } from 'react'; | |
import debounce from 'lodash.debounce'; | |
const withBreakpoint = TargetComponent => class extends Component { | |
state = { | |
breakpoint: this.getBreakpoint(), | |
}; | |
componentDidMount() { | |
window.addEventListener('resize', this.updateBreakpoint); |
import { PureComponent } from 'react'; | |
import { withRouter } from 'react-router-dom'; | |
class ScrollToTop extends PureComponent { | |
componentDidUpdate = ({ location }) => location !== this.props.location && window.scrollTo(0, 0); | |
render = () => null; | |
} | |
export default withRouter(ScrollToTop); |
const path = require('path'); | |
const fs = require('fs'); | |
const React = require('react'); | |
const { renderToString } = require('react-dom/server'); | |
const { StaticRouter } = require('react-router-dom'); | |
const { ServerStyleSheet } = require('styled-components'); | |
const { default: App } = require('../src/containers/App'); |
import normalize from 'styled-normalize'; | |
export default () => ` | |
${normalize} | |
@import url('https://fonts.googleapis.com/css?family=Open+Sans'); | |
html { | |
box-sizing: border-box; | |
} |
const express = require('express'); | |
require('babel-register')({ | |
ignore: /\/(build|node_modules|.svg)\//, | |
presets: ['env', 'react-app'] | |
}); | |
const universal = require('./universal'); | |
const app = express(); |
<snippet> | |
<content><![CDATA[ | |
export const ${1:ACTION_NAME} = '${1}'; | |
export const ${1/(?<=[^\W_])_+([^\W_])|([^\W_]+)|_+/\U$1\L$2/g} = ${2:opts} => ({ | |
type: ${1},${3:} | |
}); | |
]]></content> | |
<tabTrigger>action</tabTrigger> | |
</snippet> |
import Case from 'case'; | |
export const createAction = name => ({ | |
[Case.constant(name)]: Case.constant(name), | |
[Case.camel(name)]: payload => ({ | |
type: Case.constant(name), | |
payload, | |
}), | |
}); | |
export const createNetworkAction = name => ({ |
import { showSnackbar } from './actions'; | |
const isLocalhost = Boolean( | |
window.location.hostname === 'localhost' || | |
// [::1] is the IPv6 localhost address. | |
window.location.hostname === '[::1]' || | |
// 127.0.0.1/8 is considered localhost for IPv4. | |
window.location.hostname.match( | |
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ | |
) | |
); |