Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

Hook cannot be called inside a callback in React.js ?

By M.K. Verma · 2 May 2022

Hook cannot be called inside a callback in React.js ?

You can put your API call inside a callback and call it inside your selectbox handler.

example:

const apiCall = (item) => {
  // api call logic
}

const handleSelectBox = (selectedItem)=> {
  apiCall(selectedItem)
}