Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1847

A better way to call an async function inside an event handler

$
0
0

in ReScript is there a better way to call an async function inside an event handler than using ->ignore?

Need to call this async function inside an onClick but get compiler error unless I call it with ->ignore.

let handleDuplicateQuote = async () => {
      try {
        await mutation_duplicateQuote({quoteId: quote._id})
      } catch {
      | Js.Exn.Error(err) => Js.log2("Failure!!", err)
      }
    }

onClick

onClick={_ => { 
        handleDuplicateQuote()->ignore
 }}

I wonder if there is a better way


Viewing all articles
Browse latest Browse all 1847

Trending Articles