Search code examples
javascriptbuttonsolid-js

How to perform multiple actions when clicking on a button component?


I created a button in solid-js and I would like that when this button is clicked, a page is opened and the counter goes to zero. To perform these operations, I have already created two functions. I would like to ensure that when clicking this button that these two functions are called asynchronously. So I wrote the following code:

 <button
        onClick={[toggle, setNullCount]}
      >

with functions to call toggle and setNullCount. However, I realized that when I click on the button, only the first declared function is called and I don't know how to allow two functions to be called on click.


Solution

  • Here is a solution

    onClick={() => {toggle(); setNullCount()}}
    

    when you want assign more than one action to trigger you must create a function which handles methods that will be performed as effect.