React-native-navigation goBack() irregular - reactjs

I encountered a problem when using
"#react-navigation/bottom-tabs": "^5.11.1"and"#react-navigation/native": "^5.8.9"
snack.expo.io
the operation is as follows:
After entering the main interface, click the tabBar B PAGE bottom
Click jump to B Detail
Click the headerRight custom Back button
Why do I return to the A page? When I click the B page button at the bottom again, I will jump to the Detail page. I don’t know why. Can you help me?

I think it's because you are using navigate.goBack(); it pops the last item in the stack and navigate to that; so when you're trying to use bottom tabs for navigation, you push a new screen to the stack which gets rendered on goBack();
consider using the screen name instead;

Related

scroll to top when tapping on the active tab in react native

I know there is a hook for that https://reactnavigation.org/docs/use-scroll-to-top/ . But at the beginning of my project, i created my own bottom tab component instead of using createBottomTabNavigator(). So i have a code like that <BottomNavigator selected={'Explore'} /> at the bottom of five screen. I want to scroll to top when active tab tapped. I can understand that if active tab is tapped but i get that information in BottomNavigator component. So i have no idea how to retrieve that information back to current screen and scroll to top.

How to destroy current screen and navigate to another screen ? so that on back press that previous screen doesn't appear

Hello everyone i am new to react-native and stuck in a navigation problem. i have crawled through every question about this but found nothing helpful.
I have Navigation structure like this
Tab Navigator
HomeStack [mainScreen,Screen2]
PostStack[cameraScreen,UploadPostScreen]
Now i want to navigate to MainScreen of HomeStack after uploading the Post and along with that i want to remove these post and upload screen so that i can not go back by pressing back button.
You need to use replace method in that case, take a look here:
https://reactnavigation.org/docs/stack-actions/#replace

React-navigation tutorial missing back button

I am new to react native and I am following this tutorial from the official react-navigation docs on auth flow.
https://reactnavigation.org/docs/en/auth-flow.html
They have a really nice live example: https://snack.expo.io/#react-navigation/auth-flow-v3
After sign in, when you click on Show me more of the app from the home screen, it takes you to a page with a back button. Just from looking at the code, I can't figure out how they are able to produce this back button.
Maybe the code is not complete?
I understand that one way to a back button on the nav bar is to do something like:
headerLeft: (
<Button
onPress={() => alert('This is a button!')}
title="Info"
color="#fff"
/>
),
but this is missing from the code displayed?
React Navigation has by default provided Back button to navigate to the previous screen.
Because ios do not have a hardware back button all they have is a gesture with which they can go back. and if it is disabled then there is no way to go to the previous screen.
So default back button for stack navigator must be there and we have it.
So when there is a previous screen available back button will be there and if screen if first of its stack there will be no back button.
Let say we have one switch navigator for authentication screens like signIn, signUp etc. and one stack navigator for all other screens.
So here switch navigator by default has only one screen in its stack so none of these screens will have back button because you can't go back from here there is a dead end.
and for stack navigator, your first screen in the stack that renders before all other screens will not have a back button but all screens after that will be having back button because from there you can go back right.
React Navigation already have default Header with back button when you create switch or stack navigator. the headerLeft property is only used if you want to override the default back button. :D
Edit:
to clear things out.
The purpose of SwitchNavigator is to only ever show one screen at a time. By default, it does not handle back actions and it resets routes to their default state when you switch away. -switch navigator
where stack navigator purposely create screen on top of a stack (if you have initial screen). initial screen wont have header with back button because it doesn't know where return to. thats why when you navigate to "OtherStack" it creates new screen named "OtherStack" place on the top of "HomeScreen". newly created screens have default header with back button so you can go back to initial stack.
const AppStack = createStackNavigator({ Home: HomeScreen, Other: OtherScreen });

react navigation- navigating to a new screen from an onpress function

Hey Guys I am trying to navigate between screens. I have set up a screen called games that I am trying to get to from an on press function. When I press the image I would like to move between screens. Everything is working except it is not navigating between the screens when clicked it doesn't do anything. I am using a bottomtabnavigator and react-navigation. It works if I add the screen to the bottomtabnavigator which I dont want todo
enter image description here
enter image description here
enter image description here
Normally the right way is add screens to the navigator If you dont want to use tab navigator you have to use stack navigator for that then there is no tabs in the bottom but navigation should works
Doc for stack navigator

Polymer 1.0 paper-drawer-panel shadow and overlay

How can I make the paper-drawer-panel element behave like this site?
https://home-assistant.io/demo/
I want to be able to open and close the drawer panel even when the page is large. I also don't want there to be a drop shadow over the page when the drawer is out and the page is large, and I want the drawer to expand into the page and not overlay the "main".
I know about "forceNarrow" but it doesn't acheive what i want because it overlays the rest of the page when the drawer is active and it casts a drop shadow over the "main".
I just tested this on one of my sites with a drawer and, when I set forceNarrow to true and back again, I don't get a backdrop or anything, it is just as in the site you linked.
I am sure you know this, but for someone else stumbling on this the code would look something like this:
var drawer = document.getElementById('drawer');
drawer.forceNarrow = true;
drawer.forceNarrow = false;
Could you link to your site, or post some code here?
Edit: Here is an example

Resources