carsonwah / react-native-push-notification-popup

A <NotificationPopup/> component for presenting your own push notification in react-native app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

" null is not an object (evaluating '_this2.popup.show')"

shashi-kiwi opened this issue · comments

Hi ,
Thanks for awesome library. I am using this but i am getting " null is not an object (evaluating '_this2.popup.show')" everytime when Popup shows. Along With

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it.

My App.js is
import NotificationPopup from 'react-native-push-notification-popup';
import { requestUserPermission, messagingMethods } from './src/utils/firebase'

export default class App extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
requestUserPermission();
messagingMethods(this.props, (remoteMessage) => {
console.log('working call back', remoteMessage)
this.popup.show({
onPress: function () { console.log('Pressed') },
appIconSource: require('./src/assets/icons/logo.png'),
appTitle: 'Some App',
timeText: 'Now',
title: 'Hello World',
body: 'This is a sample message.\nTesting emoji 😀',
slideOutTime: 5000
});
});
}
render() {
return (


<>

{/* <View style={{ position: 'absolute', top: -20 }}> /}
<NotificationPopup
ref={ref => this.popup = ref}
/>
{/
*/}

        <StatusBar backgroundColor={COLOR.BLACK} barStyle="light-content" />
      </>
    </ActionSheetProvider>
  </Provider >
);

}
}
Thanks in advance. Please revert asap.
Shashi

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it.

This error indicates there are some issues in your render() function. Therefore, <NotificationPopup/> is not properly instantiated. And therefore this.popup does not exist.

The render function you provided is not complete. If you want to, you may post the complete file here and let me have a look.