From 10ae7855433a58a7b7fb86fae319b7ed93f953df Mon Sep 17 00:00:00 2001 From: Claudio Cortese Date: Mon, 3 Dec 2018 14:37:10 +0100 Subject: [PATCH] fix: now correctly removing activeClass on update --- src/Scrollspy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Scrollspy.js b/src/Scrollspy.js index 200d309..b127225 100644 --- a/src/Scrollspy.js +++ b/src/Scrollspy.js @@ -97,8 +97,10 @@ export default class Scrollspy extends Component { const { navItems } = this.state const { activeClass } = this.props - const active = navItems.find(navItem => navItem.classList.contains(activeClass)) - active && active.classList.remove(activeClass) + if (navItems) { + const active = navItems.find(navItem => navItem.classList.contains(activeClass)) + active && active.classList.remove(activeClass) + } } render() {