Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

How to go back to Previous Drawer Screen in React native

I am New to React Native. And I have created a screen for example

  1. A screen Now inside drawer I have two screen
  2. D1 screen
  3. D2 screen Now when I Move from D1 screen to D2. and then I want to Go back To D1 screen By tapping Default Back Button Of react native I am Directly Going To "A" screen. So means I want To go back to Previous Drawer Screen. please if possible help me. thanks.

here is my code of D2 screen

import React, {useRef} from 'react';
import {View,TouchableOpacity,Image, StyleSheet} from 'react-native';
import Signature from 'react-native-signature-canvas';
import { Card, Badge, Button, Block, Text } from "../components";
import { theme, mocks } from "../constants";
import { createStackNavigator, HeaderBackButton } from "react-navigation-stack";





const DigSign = () => {
        
  const ref = useRef();

  const handleSignature = (signature) => {
    console.log(signature);
  };

  const handleEmpty = () => {
    console.log('Empty');
  };

  const handleClear = () => {
    console.log('clear success!');
  };

  const handleEnd = () => {
    ref.current.readSignature();
  };
  return (
    
    

    <View style={{flex: 1}}>
       
      <Signature
        ref={ref}
        onEnd={handleEnd}

        onOK={handleSignature}
        onEmpty={handleEmpty}
        onClear={handleClear}
        descriptionText={'Sign here!'}
      />
    </View>
  );
};

export default DigSign;
question from:https://stackoverflow.com/questions/65949425/how-to-go-back-to-previous-drawer-screen-in-react-native

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can create a custom header back button and get back to D1 screen,

<View style={styles.headerContainer}>
 <TouchableOpacity onPress={() =>  this.props.navigation.navigate("D1Screen")}>
       <IonIcon name="chevron-back" size={(window.width) * 0.06} color="#000000" />
 </TouchableOpacity>
 <Text style={styles.title}>D2 Screen</Text>
</View>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...