I have followed this article from here to create react native library. I have published the library and used it in my local project. It works fine in android but when I try to run it on iOS it throws errors like:
TypeError: null is not an object (evaluating '_exampleBridge.default.showMessage').
I have already opened the library project in xcode13, it builds successfully.
Thanks in advance.
import React from 'react';
import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View, Button } from 'react-native';
import {Colors,Header} from 'react-native/Libraries/NewAppScreen';
import RNExampleBridge from 'example-bridge-1.0.8'
const App = () => {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
function showToastAlert(){
RNExampleBridge.showMessage()
}
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<View>
<Button title="Show Native Message" onPress={() => { showToastAlert() }}/>
</View>
</View>
</ScrollView>
</SafeAreaView>
);
};
export default App;