Skip to content

Commit 97d0117

Browse files
committed
fix: save methods
1 parent 6b85071 commit 97d0117

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ interface PdfScannerProps {
5656

5757
class PdfScanner extends React.Component<PdfScannerProps> {
5858
sendOnPictureTakenEvent (event: any) {
59+
if (!this.props.onPictureTaken) return null
5960
return this.props.onPictureTaken(event.nativeEvent)
6061
}
6162

@@ -74,16 +75,16 @@ class PdfScanner extends React.Component<PdfScannerProps> {
7475
componentWillMount () {
7576
if (Platform.OS === 'android') {
7677
const { onPictureTaken, onProcessing } = this.props
77-
DeviceEventEmitter.addListener('onPictureTaken', onPictureTaken)
78-
DeviceEventEmitter.addListener('onProcessingChange', onProcessing)
78+
if (onPictureTaken) DeviceEventEmitter.addListener('onPictureTaken', onPictureTaken)
79+
if (onProcessing) DeviceEventEmitter.addListener('onProcessingChange', onProcessing)
7980
}
8081
}
8182

8283
componentWillUnmount () {
8384
if (Platform.OS === 'android') {
8485
const { onPictureTaken, onProcessing } = this.props
85-
DeviceEventEmitter.removeListener('onPictureTaken', onPictureTaken)
86-
DeviceEventEmitter.removeListener('onProcessingChange', onProcessing)
86+
if (onPictureTaken) DeviceEventEmitter.removeListener('onPictureTaken', onPictureTaken)
87+
if (onProcessing) DeviceEventEmitter.removeListener('onProcessingChange', onProcessing)
8788
}
8889
}
8990

0 commit comments

Comments
 (0)