Reputation: 109
I am trying to a intergrate a materialize.css Paralex plugin into my react hook functional component. how do i do that ? here is the code
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.parallax');
var instances = M.Parallax.init(elems, options);
});
please assist
Upvotes: 0
Views: 1018
Reputation: 778
This is how you do with class components:
componentDidMount() {
var elems = document.querySelectorAll('.parallax');
var instances = M.Parallax.init(elems, options);
}
Functional components:
useEffect(() => {
var elems = document.querySelectorAll('.parallax');
var instances = M.Parallax.init(elems, options);
}, [])
Hope this is what you needed :)
Upvotes: 1