简体   繁体   English

如何在反应中使用 wow.js 或任何其他库

[英]how to use wow.js or any other library in react

I need help please I started using react in my first project and I'm facing a problem with installing wow js I searched a lot on the internet but all I found was old methods that don't work now someone help, please我需要帮助,我开始在我的第一个项目中使用 react,我在安装 wow js 时遇到问题我在互联网上搜索了很多,但我发现的只是旧方法现在不起作用,请有人帮忙

Install the dependency first先安装依赖

npm install wowjs

then import in the required component然后导入所需的组件

import WOW from 'wowjs';

and in a method componentDidMount (for class components) or a hook useEffect (for functional) create an instance and initiate并在方法componentDidMount (用于 class 组件)或钩子useEffect (用于功能)中创建实例并启动

componentDidMount() {
  new WOW.WOW({
    live: false
  }).init();
}

useEffect(() => {
  new WOW.WOW({
    live: false
  }).init();
}, [])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM