Closed lensbart closed 6 years ago
Are you importing using es6 or es5?
// ES6 Imports
import * as Scroll from 'react-scroll';
import { Link, DirectLink, Element , Events, animateScroll as scroll, scrollSpy, scroller } from 'react-scroll'
// Or Access Link,Element,etc as follows
let Link = Scroll.Link;
let Element = Scroll.Element;
let Events = Scroll.Events;
let scroll = Scroll.animateScroll;
let scrollSpy = Scroll.scrollSpy;
// ES5
var React = require('react');
var Scroll = require('react-scroll');
var Link = Scroll.Link;
var Element = Scroll.Element;
var Events = Scroll.Events;
var scroll = Scroll.animateScroll;
var scrollSpy = Scroll.scrollSpy;
ES6. The issue manifests itself both with import Scroll from 'react-scroll'
and import * as Scroll from 'react-scroll'
.
Whoops, import { animateScroll } from 'react-scroll'
solved the issue. Thanks for the quick response
I upgraded react-scroll to the latest version, and found that calling
Scroll.animateScroll.scrollTo([position in pixels], [options])
throws an errorUndefined is not an object
. Reverting to 1.6.7 fixed the issue.