Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Chedeau vjeux

View GitHub Profile
@vjeux
vjeux / gist:9045784
Created Feb 17, 2014
All browser globals
View gist:9045784
Number
Math
unescape
Object
Array
escape
Float32Array
Date
location
Int8Array
View gist:9045802
Number
Math
unescape
Object
Array
escape
Float32Array
Date
location
Int8Array
@vjeux
vjeux / gist:9474059
Created Mar 10, 2014
React Performance - JSFest
View gist:9474059
# Basic
Initial rendering takes ~25ms
Delete first takes ~30ms
Delete last takes ~15ms
Add `background: red` to the second element and delete the first, you'll
see that the second element is still red. What happened is that everything
moved around. The reason is that React doesn’t do the matching properly.
@vjeux
vjeux / ReactPerformance
Created Mar 10, 2014
React Performance
View ReactPerformance
# Basic
Initial rendering takes ~25ms
Delete first takes ~30ms
Delete last takes ~15ms
Add `background: red` to the second element and delete the first, you'll see that the second element is still red. What happened is that everything moved around. The reason is that React doesn’t do the matching properly.
http://jsfiddle.net/vjeux/tXfDU/
View gist:c87f50101b57191a2bab
var PanelList = React.createClass({
// lots of stuff that front-end engineer is working on
render: function() {
// ...
return (
<div>
View gist:30674f9d5171ce9139ce
var Button = React.createClass({
// Lots of complicated stuff
render: function() {
return (
// the designer can tweak this rendering as well
<span style={[styles.normal, this.props.active && styles.active]} >
// ...
</span>
View gist:24bb600d563e6b0e68c6
var SomeClassClosure = function() {
this.method = function() {}
}
new SomeClassClosure
// {method: fnA()}
new SomeClassClosure
// {method: fnB()} // a new fn is allocated each time
var SomeClassPrototype = function() {}
View gist:ca5c28098c3c8f394938
var SomeClass = function() {
// constructor
}
copyProperties(SomeClass, {
staticMethodA: function() {
}
})
View gist:6b390e6a6bb51e24b646
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule deepFreezeAndThrowOnMutationInDev
*/
/**
* If your application is accepting different values for the same field over
* time and is doing a diff on them, you can either (1) create a copy or
* (2) ensure that those values are not mutated behind two passes.
View gist:d1a511119b75a01d5f72
var React = React.createClass({
componentDidMount() {
// this.props instead of attrs
var xGif = this.xGif = Object.create(this.props, {
fire: {
value: function (event) {
console.log(event);
}
}