【发布时间】:2021-05-11 20:51:39
【问题描述】:
我需要在我的 react.js 应用程序中设置 react-water-wave 模块:
https://github.com/homerchen19/react-water-wave
这是我目前拥有的沙盒:
https://codesandbox.io/embed/old-leaf-iqke2?fontsize=14&hidenavigation=1&theme=dark
我面临的错误是:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
代码是:
import Background from "./background.jpeg";
import WaterWave from 'react-water-wave';
import './App.css';
function App() {
let renderFirstold = () => {
return (
<WaterWave
style={{
width: "100%",
height: "100vh",
backgroundSize: "cover",
background: `url(${Background}) no-repeat center center fixed`
}}
dropRadius={20}
perturbance={0.01}
interactive={true}
>
</WaterWave>
)
}
return (
<div className="App">
{renderFirstold()}
</div>
);
}
export default App;
如果这是问题,我可以转换回基于类的组件。 请帮帮我。
【问题讨论】:
标签: reactjs