Question: Ive got the state: const [isPressed, setIsPressed] = useState(false)
Then I want to pass the setIsPressed when navigating to another sreen, which i wrote:
On the from Screen:
onPress{() => navigation.navigate('Map', {setIsPressed})}
On the to Screen:
onPress={() => {navigation.navigate('DM'); setIsPressed(true);}}

However, I get an error saying 'setIsPressed is not a function' when pressing on the To Screen button

How do I fix this?

Answer: 
The function is called `getElementsByClassName`. It can return multiple results and if you want to attach a handler to all of the returned results, you need to iterate over them:

```html
<a href="#"class="hello-btn">Google</a>
<a href="#"class="hello-btn">Microsoft</a>
<a href="#"class="hello-btn">Facebook</a>
<a href="#"class="hello-btn">Azure</a>
<a href="#"class="hello-btn">AWS</a>

```

```js
const buttons = document.getElementsByClassName("hello-btn");

Array.from(buttons).forEach((helloBtn) => {
    helloBtn.addEventListener("click", (evt) => {
      console.log(`clicked button ${evt.target.innerHTML}`);
    });
});

```

Please note, that `getElementsByClassName` does not return an array, but an array-like object: The HTMLCollection <https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection?retiredLocale=de>

**Update:**
To get the desired auto click functionality working, you could go like this:

```js
var autoclickInterval = setInterval(()=> {
  Array.from(buttons).forEach((helloBtn) => {
      helloBtn.click()
  });
}, 5000)

//clearInterval(autoclickInterval)

```
As the class name can be used by multiple tags. `document.getElementsByClassName` returns an Array.

**If you want to allow click to all buttons having the same class name.**
Example: <https://jsfiddle.net/pLtjo5hn/>

```
  var helloBtn = document.getElementsByClassName('hello-btn');

  for(var i = 0; i < helloBtn.length; i++ ){
    var btn = helloBtn[i];
    btn.addEventListener('click', function handleClick(event) {
      console.log('btn clicked', event.target.innerText, event);
    });

```

If you want to allow click to only 1st element/button having the same class name.
Example: <https://jsfiddle.net/0vnos7xr/>

```
    var helloBtn = document.getElementsByClassName('hello-btn')[0];

    helloBtn.addEventListener('click', function handleClick(event) {
      console.log('btn clicked', event.target.innerText, event);
    });

```

*Note: If there is just 1 button to bind a click event, it is always better to use ID instead of Class Name.*