Answer the question
In order to leave comments, you need to log in
Is it possible to pass a function to a hook state?
Got a hook
const [objectData, setObjectData] = useState(GetLoan);
export async function GetLoan() {
return axios.get("/account/get-..../").then(res => res.data);
}
Answer the question
In order to leave comments, you need to log in
You can’t do this, why not pass an empty object to useState , write a function below, the results of which will be setObjectData , and even below useEffect where add [] to the dependency
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question