Skip to content

Commit

Permalink
better lifecycle methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte W committed Nov 24, 2015
1 parent 3eb5816 commit b23ec04
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/Textfit.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,11 @@ export default createClass({
this.process();
},

componentWillReceiveProps(nextProps) {
if (shallowEqual(this.props, nextProps)) return;
this.process();
},

shouldComponentUpdate(nextProps, nextState) {
componentDidUpdate(prevProps) {
const { ready } = this.state;
if (!ready) return true;
return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
if (!ready) return;
if (shallowEqual(this.props, prevProps)) return;
this.process();
},

componentWillUnmount() {
Expand Down Expand Up @@ -217,7 +213,7 @@ export default createClass({
return (
<div style={finalStyle} {...props}>
<span ref="wrapper" style={wrapperStyle}>
{!!text && typeof children === 'function'
{text && typeof children === 'function'
? ready
? children(text)
: text
Expand Down

0 comments on commit b23ec04

Please sign in to comment.