rrutsche / react-parallax

A React Component for parallax effect
MIT License
855 stars 76 forks source link

this.content.getBoundingClientRect() throwing error in Mobile Safari #37

Closed mogelbrod closed 6 years ago

mogelbrod commented 6 years ago

This line is reported to be throwing errors on Mobile Safari (v9, v10 & v11): TypeError: null is not an object (evaluating 'this.content.getBoundingClientRect')

Our error logs suggest it's happening during unmount (during route transition). I'm guessing updatePosition is being called during/after componentWillUnmount. A quick solution would be to bail if this.content is falsy.

rrutsche commented 6 years ago

@mogelbrod Thanks for the report. I will have a look a it. Which version of react are you using in your project?

mogelbrod commented 6 years ago

Appreciated! The current build is running on react@16.1.1, but we've been getting reports of the error since October 13 so It's likely present in v16.1.0 (and possibly v16.0.0) as well.

rrutsche commented 6 years ago

@mogelbrod New version 1.5.1 was just released on npm. It just does an additional check for content node before doing calculations. Hope it solves your issue.