Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

select value from select and pass it to useeffect

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>          
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: force reload when back_forward is clicked 
Javascript :: how to show numbers in javascript using while loop 
Javascript :: blank array condition in react js 
Javascript :: suisie with c 
Javascript :: js find selected input 
Javascript :: how to enable button of upload after click on chosefile in jquery 
Javascript :: react native map not loading 
Javascript :: Detectando url diferente em nodeJs 
Javascript :: petShopIndex.html:137 Uncaught ReferenceError: $ is not defined jquery node 
Javascript :: Application-level middleware 
Javascript :: turn any function into promise 
Javascript :: extracting script elements 
Javascript :: react grid generator 
Javascript :: native module reactnativepushnotification tried to override rnpushnotification 
Javascript :: salesforce lightning call javascript every x seconds 
Javascript :: how to display a title of document if a text is present in that document javascript 
Javascript :: como saber si un afecha es mayor o menor js 
Javascript :: node spawn bash catch errors 
Javascript :: what regular express will match valid internation number 
Javascript :: dlowlad the json fiel in react js pretty formate 
Javascript :: data error in jquery validate add custom element 
Javascript :: example of post increment in js 
Javascript :: new Intl.NumberFormat en react 
Javascript :: nestjs forRoutes middlewarwe 
Javascript :: tour-app-api 
Javascript :: angualr js checknbox not working js 
Javascript :: Make a ReactNative component take the height and width of the current window 
Javascript :: js import 
Javascript :: ios ad mobs 
Javascript :: Uncaught TypeError: $(...).steps is not a function 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =