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
| var article = { | |
| title: 'Hello Template Literals', | |
| teaser: 'String interpolation is awesome. Here are some features', | |
| body: 'Lots and lots of sanitized HTML', | |
| tags: ['es6', 'template-literals', 'es6-in-depth'] | |
| } | |
| function html(template, ...expressions) { | |
| return template.reduce((accumulator, part, i) => { | |
| return accumulator + expressions[i - 1] + part |
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 { connect } from 'react-redux'; | |
| import { formsReducer, FormsActions, convertFormData, haveFormDataError } from 'forms'; | |
| const FORMS_REDUCER_ID = 'forms'; | |
| const store = createStore(formsReducer); | |
| const dispach = store.dispach; |
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 { connect } from 'react-redux'; | |
| class FetchComponent extends React.Component { | |
| constructor() { | |
| super(); | |
| this.state = { | |
| dataFetched: false | |
| }; | |
| } |
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 { validator } from 'validator' | |
| import { VALIDATOR_SYMBOL } from 'validator-middleware'; | |
| const data = { x: 1, y: 2 }; | |
| const validator = validator(fn1, fn2); // curry, one data input left | |
| const action = { | |
| [VALIDATOR_SYMBOL]: { | |
| data, |
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 { validate, list, dict, required, optional } from 'validators'; | |
| pipe( | |
| validate( | |
| identity, | |
| [ | |
| required('first', isString), | |
| optional('second', list(isString), []), | |
| // required(['third', 'subParam', 'deepParam'], isNumber) |
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
| <Ratio width={Ratio.OPTIONS.FLUID} x={3} y={4}> | |
| {(width, height) => ( | |
| <Chart id={this.props.id} width={width} height={height} /> | |
| )} | |
| </Ratio> |
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, { createElement } from 'react'; | |
| import { render } from 'react-dom'; | |
| import { Provider, connect } from 'react-redux'; | |
| import { store } from 'store'; | |
| const TypeConnector = connect(({ router: { type } }) => { | |
| return { | |
| type | |
| }; |
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, { createElement } from 'react'; | |
| import { createStore } from 'redux'; | |
| import { render } from 'react-dom'; | |
| import { Provider, connect } from 'react-redux'; | |
| const ADD = 'ADD'; | |
| const store = createStore((state = 0, action) => { | |
| if (action.type === ADD) { | |
| return ++state; |
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
| rm -rf ./node_modules | |
| npm cache clear --force | |
| npm install | |
| # If the problem persists | |
| rm ./package-lock.json | |
| rm -rf ./node_modules | |
| npm cache clear --force | |
| npm install |
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 Optimized extends React.PureComponent { | |
| render() { | |
| return this.props.children | |
| } | |
| } | |
| const SomeConsumer = ({ slice, children } => ( | |
| <ActualConsumer> | |
| {(state) => ( | |
| <Optimized slice={state[slice]}> |