fixed warning in all tsx file except for CameraView.tsx

This commit is contained in:
2024-06-10 21:54:22 +08:00
parent 4dfbbe7cbd
commit 7e0e9ec1bb
4 changed files with 41 additions and 25 deletions

View File

@@ -3,8 +3,12 @@ import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
import { QRCodeContext } from '../types';
const SettingsScreen: React.FC = () => {
const { setQrCodes } = useContext(QRCodeContext);
const qrCodeContext = useContext(QRCodeContext);
// Safely access setQrCodes and handle the case when the context is null
const setQrCodes = qrCodeContext ? qrCodeContext.setQrCodes : () => {};
const clearHistory = () => {
setQrCodes([]);
};