如何一次测试useEffect
,所以我正在装入许多链接。因此它只会被调用一次
查看代码
app.js
import React, { useState, useEffect } from "react";
const App = () => {
const [links, setLinks] = useState([]);
useEffect(() => {
const links = createLinks();
setLinks(links);
}, []);
const createLinks = () => {
return [{ link: "https://www.google.com", text: "Google" }];
};
return <>{links.length && links.map(({ link, text }) => <a href={link}>{text}</a>)}</>;
};
export default App
我如何使用笑话和酶为上述示例应用程序组件编写测试用例