From 942106b88c832cca333e315fd2dd3a96b2831e0c Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 28 Jan 2019 16:55:00 +0100 Subject: [PATCH] only update url if element exists --- src/components/Scroll.jsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/Scroll.jsx b/src/components/Scroll.jsx index e50270ab..06fbfae4 100644 --- a/src/components/Scroll.jsx +++ b/src/components/Scroll.jsx @@ -37,13 +37,15 @@ export default class TocScroll extends React.Component { } } - scroll - ? this.scrollTo(elem, offset, timeout) - : console.log(`Element not found: ${element}`) // eslint-disable-line + if (scroll) { + this.scrollTo(elem, offset, timeout) - // update browser url - if (typeof window !== 'undefined') { - window.history.pushState({}, null, `#${element}`) + // update browser url + if (typeof window !== 'undefined') { + window.history.pushState({}, null, `#${element}`) + } + } else { + console.log(`Element not found: ${element}`) // eslint-disable-line } }