This file contains hidden or 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
'use strict' | |
const http2 = require('http2') | |
const fs = require('fs') | |
const path = require('path') | |
const helper = require('./helper') | |
const { HTTP2_HEADER_PATH } = http2.constants | |
const PUBLIC_PATH = path.join(__dirname, '../public') | |
const SSL_PATH = path.join(__dirname, '../ssl') |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello HTTP/2</title> | |
<link rel="stylesheet" href="/app.css" media="all"> | |
</head> | |
<body> | |
<h1>Hello HTTP/2</h1> | |
<script src="app.js"/></script> |
This file contains hidden or 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 { compose, withState, mapProps } from 'recompose'; | |
const FooComponent = (props) => ( | |
<div> | |
<h1> | |
Clicks: { props.count } | |
</h1> | |
<button onClick={props.incrementCount}>+</button> | |
<button onClick={props.decrementCount}>-</button> |
This file contains hidden or 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'; | |
const mapProps = mapFn => BaseComponent => | |
(props) => ( | |
<BaseComponent | |
{...mapFn(props)} | |
/> | |
); | |
export default mapProps; |
This file contains hidden or 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 withState from './withState'; | |
import mapProps from './mapProps'; | |
const FooComponent = (props) => ( | |
<div> | |
<h1> | |
Clicks: { props.count } | |
</h1> | |
<button onClick={props.incrementCount}>+</button> |
This file contains hidden or 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 withState from './withState'; | |
const FooComponent = (props) => ( | |
<div> | |
<h1> | |
Clicks: { props.count } | |
</h1> | |
<button onClick={() => props.updateCount((count) => count + 1)}>+</button> | |
<hr /> |
This file contains hidden or 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'; | |
const withState = (stateName, stateUpdateName, initialValue) => BaseComponent => | |
class extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
value: initialValue, | |
}; | |
} |
This file contains hidden or 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 withState from './withState'; | |
const FooComponent = (props) => ( | |
<div> | |
<h1> | |
Clicks: { props.count } | |
</h1> | |
<button onClick={() => props.updateCount((count) => count + 1)}>+</button> | |
<hr /> |
This file contains hidden or 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
class NoHoC extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
count: 0, | |
text: '', | |
}; | |
this.incrementCount = this.incrementCount.bind(this); | |
this.onTextChange = this.onTextChange.bind(this); | |
} |
This file contains hidden or 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 removeSpecialChar = word => word.replace(/[^a-zA-Z0-9]/g, ''); | |
const split = splitOn => str => str.split(splitOn); | |
const toLowerCase = word => word.toLowerCase(); | |
const join = str => arr => arr.join(str); | |
const map = fn => arr => arr.map(fn); | |
const compose = (...fns) => x => fns.reduceRight((v, f) => f(v), x); | |
// without compose | |
const toSlug = input => join('-')( | |
map(toLowerCase)( |
NewerOlder