I am not sure how to describe my problem, but essentially I am attempting to type-check a function but I am unsure if my understanding is correct.
I have these props over here
const { closeModal, productId, activeEnvironment } = props;
Now I already know that productId is a string and so is activeEnvironment, but closeModal is a function, now I figured this out by outputting it to the console in a console log statement.
This is what was outputted in the browser console.
ƒ closeModal() {
setManualBeatModalOpen(false);
}
Here is the usage of my ManualPulseModal
<ManualBeatForm
productId={productId}
closeModal={() => {
setManualBeatModalOpen(false);
}}
activeEnvironment={activeEnvironment}
/>
Now how would I type check the closeModal variable do I need to use Dispatch....etc
CodePudding user response:
Since the closeModal
has no parameters and no return value, you can type it simply as closeModal : () => void
.
So you could have something similar to this (excluding the other props):
interface Props {
closeModal : () => void
}
export function YourFunc(props : Props) {
const { closeModal } = props;
...
}