📌  相关文章
📜  从 select 中选择值并将其传递给 useeffect - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:02.705000             🧑  作者: Mango

代码示例1
const GetAPILinks = () => {
  const [apiData, setApiData] = React.useState([]);
  const [fetchUrl, setFetchUrl] = React.useState('');
  React.useEffect(() => {
    if (fetchUrl) {
      fetch(fetchUrl)
        .then((response) => {
          return response.json();
        })
        .then((data) => {
          setApiData(data);
        });
    }
  }, [fetchUrl]);

  return (
    {setFetchUrl(e.target.eventKey)}}>
        Link 1
        Link 2
        Link 3
              
  );
}