I want to update state of `tickerList` variable, with the `data.ticker`
i tried doing like `setTicker(data.ticker)` but this doesn't change state of `tickerList` variable

how to do this?

```
  const [tickerList, setTickerList] = useState([]);

  fetch('/ticker').then(res => res.json()).then(data => {

         setTickerList(data.ticker)     // here i  want to assign data.ticker to tickerList
         console.log(data.ticker)       // prints list of strings
         console.log(tickerList)        // prints empty list

  })

update 1

  useEffect(()=>{

    fetch('/ticker').then(res => res.json()).then(data => {
         setTickerList(data.ticker)  
    })

    console.log(tickerList)
  },[tickerList])

```

by doing as above, `/ticker` endpoint is getting called infinitely
any way to avoid that?

**update 2**

```
 const handleClick =  () =>{
     fetch('/ticker').then(res => res.json()).then(data => {
         setTickerList(data.ticker)  
    })

  }

```