我正在尝试从 firebase 加载一些图像,并使用机车滚动反应模块让它们水平滚动。但是,每当我添加下面的 useEffect 部分来初始化机车滚动时,我都会收到以下错误:
我已经按照 LocomotiveScroll 网站和 GitHub 页面上的所有说明进行操作,还查看了其他示例,但似乎无法弄清楚。或者甚至可能我错过了一些东西。
import React, { useEffect } from "react";
import useFirestore from "../../Hooks/useFirestore";
import "./Astro.css";
import LocomotiveScroll from "locomotive-scroll";
//<a class="gallery__item-link">explore</a>
const Astro = (props) => {
const { docs } = useFirestore("astro");
let i = 1;
const scrollReff = React.createRef();
useEffect(() => {
const scroll = new LocomotiveScroll({
el: scrollReff.current,
smooth: true,
direction: "horizontal"
});
});
return (
<div>
{docs &&
docs.map((doc) => (
<div key={doc.id}>
<div ref={scrollReff}>
<div className="content">
<div className="gallery">
<figure className="gallery__item">
<div className="gallery__item-img">
<div class="gallery__item-img">
<div
class="gallery__item-imginner"
>
<img src={doc.url} alt={doc.description} />
</div>
</div>
</div>
<figcaption className="gallery__item-caption">
<h2
className="gallery__item-title"
data-scroll
data-scroll-speed="1"
>
{doc.title}
</h2>
<span className="gallery__item-number">{"0" + i++}</span>
</figcaption>
</figure>
</div>
</div>
</div>
</div>
))}
</div>
);
};
export default Astro;