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

"recursion" in a function argument via callback

$
0
0

Can you give the full example of what you are trying to do? Is just the registerSW function external or updateSW as well? You are not using any external keyword here.

If the signature of “registerSW” is like you wrote then the update function can be written like this:

type opts = {foo: React.element}

@val
external registerSW: opts => unit => unit = "registerSW"

let rec updateSW = () =>
  registerSW({foo: <button onClick={_ => updateSW()} />})->ignore

Viewing all articles
Browse latest Browse all 2592

Trending Articles