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

"recursion" in a function argument via callback

$
0
0

The updateSW is a return of the registerSW, so it is intrinsically external as the registerSW is external. I’m loading it from the Vite PWA plugin, the binding is like

@module("virtual:pwa-register")
external registerSW: registerSWOptions => unit => unit = "registerSW"

and let’s say the registerSWOptions has the type

type registerSWOptions = {foo: React.element}

for simplicity.

I name the return type () => () a updateSW but it is only my assignment.

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

Your example would not work, as the updateSW calls registerSW in it’s body, but it should not do that - the updateSW is simply and external function returned by the registerSW.


Viewing all articles
Browse latest Browse all 1969

Trending Articles