I'm trying to use Rellax, a JS parallax library, in my React app.
I've downloaded Rellax through npm and imported Rellax into a React component. Rellax's docs then require assigning a rellax variable to the new Rellax constructor, which takes as an argument the query selector.
Like so:
var rellax = new Rellax('.rellax');
However, when I call the component, I receive this error:
Error: The elements you're trying to select don't exist.
However, I do use this class in the component itself.
Below is the full component:
import React from 'react';
import Rellax from 'rellax';
import 'sample.css';
var rellax = new Rellax('.rellax');
const SampleComponent = () => {
return (<div>
<div className="rellax square"></div>
<div className="rellax rectangle"></div>
</div>);
}
export default SampleComponent;
Does anyone have any idea why this isn't working?
Below is a link to Rellax docs: https://github.com/dixonandmoe/rellax
Thanks!