pure-stateless
Advanced tools
Comparing version 1.0.2 to 1.0.4
var createClass = require('react').createClass | ||
var shallowEqual = require('fbjs/lib/shallowEqual') | ||
var noop = function(){} | ||
@@ -14,2 +15,4 @@ module.exports = function pureStateless(statelessComponent) { | ||
const statelessWillMount = statelessComponent.statelessWillMount || noop | ||
return createClass({ | ||
@@ -23,3 +26,4 @@ displayName: statelessComponent.displayName, | ||
componentWillMount: function(){ | ||
statelessComponent.statelessWillMount(this) | ||
const result = statelessWillMount(this, this.props, this.context) | ||
result && Object.assign(this, result) | ||
}, | ||
@@ -26,0 +30,0 @@ render: function() { |
{ | ||
"name": "pure-stateless", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Pure Stateless React Components", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,9 +13,6 @@ # pure-stateless - Simple and fast React components | ||
const PureStateLessComponent = pureStateless({ | ||
statelessWillMount: self => { | ||
// the onClick handler will be created only once | ||
self.onClick = e => { | ||
const {handleClick, index} = self.props | ||
handleClick(index) | ||
} | ||
}, | ||
// the onClick handler will be created only once | ||
statelessWillMount: (self, {handleClick, index}) => ({ | ||
onClick: e => handleClick(index) | ||
}), | ||
render: (self, {value}) => { | ||
@@ -22,0 +19,0 @@ return ( |
@@ -8,3 +8,3 @@ import React, {Component} from 'react' | ||
console.log('StateLessComponent creating onClick.') | ||
console.log('StateLessComponent (not the stateless pure one) creating onClick.') | ||
const onClick = e => handleClick(index) | ||
@@ -32,10 +32,6 @@ | ||
const PureStateLessComponent = pureStateless({ | ||
statelessWillMount: self => { | ||
console.log('PureStateLessComponent creating onClick.') | ||
// the onClick handler will be created only once | ||
self.onClick = e => { | ||
const {handleClick, index} = self.props | ||
handleClick(index) | ||
} | ||
}, | ||
// the onClick handler will be created only once | ||
statelessWillMount: (self, {handleClick, index}) => ({ | ||
onClick: e => handleClick(index) | ||
}), | ||
render: (self, {value}) => { | ||
@@ -42,0 +38,0 @@ return ( |
Sorry, the diff of this file is not supported yet
203465
112
101