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