Question: I am trying to bulk import xlsx file into Azure database directly, i cannot use Blob or ADF or SSIS for this purpose, it has to be excel import into Azure database. I have tried many scripts available on internet including DBA tool but non of them work. The table is already created on Azure DB, 

The kind of data i have it does not work well with .CSV or .txt, so i cannot use BLOB or ADF, also, the first i challenge i am facing with powershell is connection, not able to establish connection with the Azure database

Answer: 
Hooks cannot be initiated conditionally or on user actions. However what you are trying to do is call the state updater method on a user action which is correct and that is precisely why the updater method is available.

Also there is no difference between your first and second approach apart from the fact that you are taking out the function in the enclosing scope and giving it a name instead of defining it inline
Yes, it's fine to call your `setCount` method inline like your example. 

All you're doing here is passing a function that will be called when the button is clicked - it's up to you whether you want to declare the function inline [your 2nd example], or refer to a variable that returns the constant [your 1st example].

You might find it more readable to do things inline when the component has very simple logic like yours. React-use is a popular library of hooks. They do it this way [in their docs](https://streamich.github.io/react-use/?path=/story/state-usecounter--docs).

However, if you need to perform bunch of other actions inside the function before calling setCount, then it will probably be more readable to reference the function instead. For example:

```
const myComplicatedAdderFunction = () => { 
  // do other stuff
  setCount(count + 1) 
}

...

<button onClick={myComplicatedAdderFunction}>+</button>

```