Skip to content

Instantly share code, notes, and snippets.

@franzejr
Created April 27, 2016 02:43
Show Gist options
  • Save franzejr/9dfb0be9e3f28365b837a45d53036336 to your computer and use it in GitHub Desktop.
Save franzejr/9dfb0be9e3f28365b837a45d53036336 to your computer and use it in GitHub Desktop.
Good Component
var GoodComponent = withScroll(React.createClass({
getInitialState: function() {
return {
someNewState: ''
}
},
componentWillReceiveProps: function(nextProps) {
var {scroll} = this.props;
// do something with scroll props
},
render: function() {
var {someNewState} = this.state
return (
<div
className="my-fixed-div"
style={{
visibility: (this.props.scroll >= 100) ? 'visible' : 'hidden'
}} />
)
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment