Hey everyone, I’m stuck with a weird issue in my React Native login screen. I’ve got a ‘Forgot Password’ button that should open a modal with a website inside. It was working fine before, but now I’m getting a ‘null is not an object’ error. I think the problem might be in the WebViewModal component.
Here’s a simplified version of what I’m trying to do:
import React, { useState, useRef } from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import { Modalize } from 'react-native-modalize';
import WebViewModalProvider, { WebViewModal } from 'react-native-webview-modal';
const PasswordResetScreen = () => {
const [isModalVisible, setModalVisible] = useState(false);
const modalRef = useRef(null);
const openModal = () => {
modalRef.current?.open();
setModalVisible(true);
};
return (
<View>
<TouchableOpacity onPress={openModal}>
<Text>Reset Password</Text>
</TouchableOpacity>
<Modalize ref={modalRef}>
<WebViewModalProvider>
<WebViewModal
visible={isModalVisible}
source={{ uri: 'https://example.com/reset-password' }}
/>
</WebViewModalProvider>
</Modalize>
</View>
);
};
export default PasswordResetScreen;
The modal opens fine when I remove the WebViewModal part, but with it, I get the error. Any ideas what might be causing this? Thanks!