Pilih Nilai dari Pilih dan Lewati ke EFFEFFECT
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 (
<DropdownButton id="dropdown-item-button" title="API Links" onSelect={(e)=>{setFetchUrl(e.target.eventKey)}}>
<Dropdown.Item as="button" eventKey='API_Link1'>Link 1</Dropdown.Item>
<Dropdown.Item as="button" eventKey='API_Link2'>Link 2</Dropdown.Item>
<Dropdown.Item as="button" eventKey='API_Link3'>Link 3</Dropdown.Item>
</DropdownButton>
);
}
Lonely Lyrebird