How to do it...

  1. We'll start by working on the App component. First, let's import all the required dependencies:
import React, { Component } from 'react';import {  Text,  TouchableOpacity,  StyleSheet,  View,  SafeAreaView,} from 'react-native';import Notification from './Notification';
  1. Once we have all the dependencies imported, we can define the App class. In this case, we are going to initialize the state with a notify property equal to false. We are going to use this property to show or hide the notification. By default, the notification will not be shown onscreen. To make things simple, we will define the message property in the state with the text we want to display:
export default class App extends Component {  state = { notify: false, ...

Get React Native Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.