I have this component that has these props:
export type Props = NavigationScreenProps & {
name: string
testCallback?: () => void
}
How do I check if this callback exists and then call the callback?
I have this component that has these props:
export type Props = NavigationScreenProps & {
name: string
testCallback?: () => void
}
How do I check if this callback exists and then call the callback?
You can simply do
const {testCallback = null} = props || {}
if(testCallback){
testCallback()
}