title: Not able to switch between screens from class component ,every time throwing an error as undefined
body: <p>I have the following code for intro slider</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { Component } from 'react';
  import { Dimensions,Platform,ScrollView,StyleSheet,View } from 'react-native';
  import Button from './Button';
  const { width, height } = Dimensions.get('window');
  export default class OnboardingScreens extends Component {
    state = this.initState(this.props);
  
    /*** Initialize the state*/
    initState(props) {
  
      // Get the total number of slides passed as children
      const total = props.children ? props.children.length || 1 : 0,
        // Current index
        index = total &gt; 1 ? Math.min(props.index, total - 1) : 0,
        // Current offset
        offset = width * index;
      
      const state = {
        total,
        index,
        offset,
        width,
        height,
  
      };
  
      this.internals = {
        isScrolling: false,
        offset
      };
  
      return state;
    }
  
  }
  
  
    renderScrollView = pages =&gt; {
      return (
        &lt;ScrollView ref={component =&gt; { this.scrollView = component; }}
          {...this.props}
          contentContainerStyle={[styles.wrapper, this.props.style]}
          onScrollBeginDrag={this.onScrollBegin}
          onMomentumScrollEnd={this.onScrollEnd}
          onScrollEndDrag={this.onScrollEndDrag}
        &gt;
          {pages.map((page, i) =&gt;
            // Render each slide inside a View
            &lt;View style={[styles.fullScreen, styles.slide]} key={i}&gt;
              {page}
            &lt;/View&gt;
          )}
        &lt;/ScrollView&gt;
      );
    }
  
    /**
     * Render pagination indicators
     */
    renderPagination = () =&gt; {
      if (this.state.total &lt;= 1) {
        return null;
      }
  
      const ActiveDot = &lt;View style={[styles.dot, styles.activeDot]} /&gt;,
        Dot = &lt;View style={styles.dot} /&gt;;
  
      let dots = [];
  
      for (let key = 0; key &lt; this.state.total; key++) {
        dots.push(key === this.state.index
          // Active dot
          ? React.cloneElement(ActiveDot, { key })
          // Other dots
          : React.cloneElement(Dot, { key })
        );
      }
  
      return (
        &lt;View
          pointerEvents="none"
          style={[styles.pagination, styles.fullScreen]}
        &gt;
          {dots}
        &lt;/View&gt;
      );
    }
  
  
  //render buttons
  
  
    renderButton = () =&gt; {
      const lastScreen = this.state.index === this.state.total - 1;
      
      return (
        &lt;View pointerEvents="box-none" style={[styles.buttonWrapper, styles.fullScreen]}&gt;
          {lastScreen
            // Show this button on the last screen
            // TODO: Add a handler that would send a user to your app after onboarding is complete
            ? &lt;Button text="Next" onPress={() =&gt;this.props.navigation.navigate("Login")} /&gt;
            // Or this one otherwise
            : &lt;Button text="Next" onPress={() =&gt; this.swipe()} /&gt;
          }
        &lt;/View&gt;
      );
    }
    
    
   render = ({ children } = this.props) =&gt; {
      return (
        &lt;View style={[styles.container, styles.fullScreen]}&gt;
          {/* Render screens */}
          {this.renderScrollView(children)}
          {/* Render pagination */}
          {this.renderPagination()}
          {/* Render Continue or Done button */}
          {this.renderButton()}
        &lt;/View&gt;
      );
    }</code></pre>
  </div>
  </div>
  </p>
  <p>when the last screen reached on click button it should navigate to the Login page but it is throwing an error</p>
  <pre><code> TypeError: undefined is not an object (evaluating '_this.props.navigation.navigate')
  </code></pre>
  <p>I tried many alternatives and other StackOverflow solution but nothing work</p>
  <p>I don't know where I am doing wrong please help or any suggestions?
  Thanks in advance</p>