I have callback in interface:
interface { onLoad?: () => void; }
I tried to catch this callback using this:
props.onLoad(() => this.mapLoaded = true);
But I get this error:
Expected 0 arguments, but got 1.
Advertisement
Answer
It’s hard to say for certain without more context, but you’re probably meant to assign to onLoad
rather than call it:
props.onLoad = () => this.mapLoaded = true;
Typically, a callback is called by the object you’re passing the interface to, so that it can call back to your code when something happens (in this case, presumably when a map is loaded).