fisshy / react-scroll

React scroll component
https://github.com/fisshy/react-scroll/blob/master/README.md
MIT License
4.36k stars 436 forks source link

1.7.0 breaks Scroll.animateScroll on Safari #287

Closed lensbart closed 6 years ago

lensbart commented 6 years ago

I upgraded react-scroll to the latest version, and found that calling Scroll.animateScroll.scrollTo([position in pixels], [options]) throws an error Undefined is not an object. Reverting to 1.6.7 fixed the issue.

fisshy commented 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;
lensbart commented 6 years ago

ES6. The issue manifests itself both with import Scroll from 'react-scroll' and import * as Scroll from 'react-scroll'.

lensbart commented 6 years ago

Whoops, import { animateScroll } from 'react-scroll' solved the issue. Thanks for the quick response