This file contains 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
export default function arrayShallowEqual(left, right) { | |
if(left.length !== right.length) { | |
return false | |
} | |
return !left.some((item, index) => item !== right[index]) | |
} |
This file contains 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
// ES6 tl;dr; for beginners | |
// 1. variables | |
// `const` & `let` are scoped at the block level | |
if(true) { | |
let foo = "bar" | |
} | |
foo // ReferenceError | |
This file contains 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 ImmutableDate extends Date { | |
constructor(...args) { | |
this._date = new Date(...args) | |
} | |
} | |
const methods = { | |
toString: false, | |
toISOString: false, | |
toUTCString: false, |
This file contains 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 AccessibleComponent extends Component { | |
render() { | |
return ( | |
<div> | |
<div aria-label={this.props.label}>foo</div> | |
</div> | |
) | |
} | |
} |
This file contains 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, {Component} from "react" | |
import shallowEqual from "react/lib/shallowEqual" | |
/** | |
* example : | |
* | |
* import React, {Component, PropTypes} from "react" | |
* | |
* class MyComponent extends Component { | |
* |
This file contains 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 origin = window.pageYOffset | |
const destination = 3000 | |
animate({ | |
duration : 500, | |
tick(progress) { | |
window.scrollTo( | |
0, | |
progress * destination + | |
(1 - progress) * origin |
This file contains 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
export default class Store { | |
listeners = new Set() | |
constructor(dispatcher) { | |
this.reactions = this.getActionHandlers() | |
this.dispatcher = null | |
this.dispatchToken = null | |
this.actionHandler = this.actionHandler.bind(this) | |
this._getOriginalState() |
This file contains 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
+----------------+ | |
| INITIALISATION | | |
+--+-------------+ | |
| | |
+--v--------------------+ | |
+-------+ INITIAL DATA FETCHING | | |
| +--+--------------------+ | |
| | | |
| +--v------------------+ | |
| | DOM EVENT LISTENING | |