Q:

Code slows down browser performance with time

I am working on a project for my Web Programming course in University. I am almost done with the homepage, however, when I test the code, I noticed it slows down with every time the scroll event is triggered.
The event handles changing the look of my nav bar, when it's on top of the page, you get it on the top right with the elements listed vertically, everywhere else on the page it is right below the title bar with elements listed horizontally.
I am not going to paste the code entirely on the thread, since I do not know from where the problem is occurring. I will paste a link to my GitHub repo of my project instead.
https://github.com/edargham/Project-CSC443-Web

A:

This line is executed each time the component renders, which means you add exponentially more and more listeners to the scroll event on window. You should do this only once.
EDIT:
The usual way of doing this is to add a listener in the componentWillMount or componentDidMount and remove it in componentWillUnmount. More on what kind of functions you should use for this here.

