0

I want to call function apiCall() every time the Cancel button is clicked and setSave() and setCreate() functions conditionally. Is there any way other than the wrapper function that I can use. I am using Functional component and setSave and setCreate functions are useState functions and apiCall() is a function which I have received as a prop from parent function.

<input type="button" onClick={() => (id !== '' ? setSave(true) : setCreate(false))} value="Cancel" /> 

1 Answer 1

1

Try this one:

 <input type="button" onClick={() => { apiCall(); if(id !== ''){ setSave(true); }else{ setCreate(false); } } value="Cancel" /> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.