You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportconstsomeForm=()=>{const[alert,setAlert]=useState({type: "",message: ""});constsubmitHandler=async()=>{try{// Make actual API call heresetAlert({type: "success",message: "some response message from api call",});}catch(error){setAlert({type: "error",message: error.message});}};constUI=html`<div><form><div>${alert.current().message&&html`<div>${Alert({type: alert.current().type,message: alert.current().message,})}</div>`}</div><buttontype="button" onClick="${submitHandler}">Submit</button></form></div>`;returnreactive(()=>UI);};
The code tries to show an alert message based on the API response but it is not shown upon response. The alert variable updates to the latest value.
The text was updated successfully, but these errors were encountered:
The code tries to show an alert message based on the API response but it is not shown upon response. The
alert
variable updates to the latest value.The text was updated successfully, but these errors were encountered: