Skip to content

Instantly share code, notes, and snippets.

@franzejr
Created April 27, 2016 02:07
Show Gist options
  • Save franzejr/4ab85f846e0ff1abaabe7d435afeede9 to your computer and use it in GitHub Desktop.
Save franzejr/4ab85f846e0ff1abaabe7d435afeede9 to your computer and use it in GitHub Desktop.
Wrong Component using jQuery
var myWrongComponent2 = React.createClass({
changeVisibility: function(scroll){
if (scroll >= 100) {
$(".my-fixed-div").css('visibility', 'visible');
}
else{
$(".my-fixed-div").css('visibility', 'hidden');
}
},
handleScroll: function () {
var scroll = $(window).scrollTop();
// some logic ...
this.changeVisibility(scroll);
},
componentDidMount: function () {
document.addEventListener('scroll', this.handleScroll);
},
render: function(){
return(<div className="fixed-div" />)
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment