Skip to content

Remove active class / JS Navigation

I have been trying for hours now, but can not figure my way out of this one. The Menu contains a regular submenu which gets an “active” class. Great, done with foreach. But how can I remove the active class when the user clicks anywhere in the document? If I put an id on the body that removes the …

Javascript Waypoints (or alternative)

I tryied to use the Waypoints library to fire an event when we scroll to the end of a div (in order to implement an “infinite scolling”-like functionality). I looked at this example but it apparently doesn’t work if I use a custom scrollable ‘div’, it only works for the window sc…

Comparing length of strings in an array?

Hi I’m trying to compare the length of each word in a sentence. I converted this sentence into an array but then I’m lost in my codes. I tried 2 methods – for loop and reduce(), but neither worked. What happened in my code? Reduce() => This one gave me undefined when I try to run the func…

Child component not re-rendering with updated props

I have a child component, it looks through and creates Canvas elements in the DOM, then useEffect() draws things to these Canvases: And it’s parent component: When the suer clicks on the Dropdown, I pass the value back up to the parent component (Workspace). This then updates the Workspace state, and I …