Handling device back button in react native
I am handling the Android back button in React-Native using BackHandler in home page its working fine, when i navigate to home page from login page. But when i go to page 2 from home page and came back to home page by clicking the device back button, now when i click device back button in home page its taking me to login page, this should not happen.
Navigation used in home page is a drawer navigation.
I am removing the backpress event handler when i am navigating to page2, because it is disabling the back button in page 2 also.
react-native
add a comment |
I am handling the Android back button in React-Native using BackHandler in home page its working fine, when i navigate to home page from login page. But when i go to page 2 from home page and came back to home page by clicking the device back button, now when i click device back button in home page its taking me to login page, this should not happen.
Navigation used in home page is a drawer navigation.
I am removing the backpress event handler when i am navigating to page2, because it is disabling the back button in page 2 also.
react-native
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality.
– AnonymousSB
Nov 20 '18 at 9:49
can u provide a sample example for above
– Sreedhar L
Nov 26 '18 at 11:22
Here's a stripped down version of what I use. I'm usingredux
andredux-saga
. This particular snippet is from an app usingreact-navigation ^1.0.0-beta.15
– AnonymousSB
Nov 26 '18 at 11:44
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:59
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a Native Module to do this, or maybe someone has already made one.
– AnonymousSB
Nov 29 '18 at 7:13
add a comment |
I am handling the Android back button in React-Native using BackHandler in home page its working fine, when i navigate to home page from login page. But when i go to page 2 from home page and came back to home page by clicking the device back button, now when i click device back button in home page its taking me to login page, this should not happen.
Navigation used in home page is a drawer navigation.
I am removing the backpress event handler when i am navigating to page2, because it is disabling the back button in page 2 also.
react-native
I am handling the Android back button in React-Native using BackHandler in home page its working fine, when i navigate to home page from login page. But when i go to page 2 from home page and came back to home page by clicking the device back button, now when i click device back button in home page its taking me to login page, this should not happen.
Navigation used in home page is a drawer navigation.
I am removing the backpress event handler when i am navigating to page2, because it is disabling the back button in page 2 also.
react-native
react-native
edited Nov 20 '18 at 8:49
Nirmalsinh
3,24331437
3,24331437
asked Nov 20 '18 at 8:46
Sreedhar LSreedhar L
62
62
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality.
– AnonymousSB
Nov 20 '18 at 9:49
can u provide a sample example for above
– Sreedhar L
Nov 26 '18 at 11:22
Here's a stripped down version of what I use. I'm usingredux
andredux-saga
. This particular snippet is from an app usingreact-navigation ^1.0.0-beta.15
– AnonymousSB
Nov 26 '18 at 11:44
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:59
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a Native Module to do this, or maybe someone has already made one.
– AnonymousSB
Nov 29 '18 at 7:13
add a comment |
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality.
– AnonymousSB
Nov 20 '18 at 9:49
can u provide a sample example for above
– Sreedhar L
Nov 26 '18 at 11:22
Here's a stripped down version of what I use. I'm usingredux
andredux-saga
. This particular snippet is from an app usingreact-navigation ^1.0.0-beta.15
– AnonymousSB
Nov 26 '18 at 11:44
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:59
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a Native Module to do this, or maybe someone has already made one.
– AnonymousSB
Nov 29 '18 at 7:13
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality.
– AnonymousSB
Nov 20 '18 at 9:49
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality.
– AnonymousSB
Nov 20 '18 at 9:49
can u provide a sample example for above
– Sreedhar L
Nov 26 '18 at 11:22
can u provide a sample example for above
– Sreedhar L
Nov 26 '18 at 11:22
Here's a stripped down version of what I use. I'm using
redux
and redux-saga
. This particular snippet is from an app using react-navigation ^1.0.0-beta.15
– AnonymousSB
Nov 26 '18 at 11:44
Here's a stripped down version of what I use. I'm using
redux
and redux-saga
. This particular snippet is from an app using react-navigation ^1.0.0-beta.15
– AnonymousSB
Nov 26 '18 at 11:44
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:59
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:59
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a Native Module to do this, or maybe someone has already made one.
– AnonymousSB
Nov 29 '18 at 7:13
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a Native Module to do this, or maybe someone has already made one.
– AnonymousSB
Nov 29 '18 at 7:13
add a comment |
1 Answer
1
active
oldest
votes
You just have to implement the Backhandler in your home page, and don't perform any action on it.
BackHandler.addEventListener('hardwareBackPress', () => {
return false
});
Just return false. So It won't navigation to Login screen again.
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389183%2fhandling-device-back-button-in-react-native%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You just have to implement the Backhandler in your home page, and don't perform any action on it.
BackHandler.addEventListener('hardwareBackPress', () => {
return false
});
Just return false. So It won't navigation to Login screen again.
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
add a comment |
You just have to implement the Backhandler in your home page, and don't perform any action on it.
BackHandler.addEventListener('hardwareBackPress', () => {
return false
});
Just return false. So It won't navigation to Login screen again.
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
add a comment |
You just have to implement the Backhandler in your home page, and don't perform any action on it.
BackHandler.addEventListener('hardwareBackPress', () => {
return false
});
Just return false. So It won't navigation to Login screen again.
You just have to implement the Backhandler in your home page, and don't perform any action on it.
BackHandler.addEventListener('hardwareBackPress', () => {
return false
});
Just return false. So It won't navigation to Login screen again.
answered Nov 20 '18 at 8:51
NirmalsinhNirmalsinh
3,24331437
3,24331437
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
add a comment |
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:58
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
You need to give path of your image. You need to add image on one of your folder, not in particular iOS and Android folder.
– Nirmalsinh
Nov 29 '18 at 7:00
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389183%2fhandling-device-back-button-in-react-native%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should have two stacks, one for login, the other for you app, and reset the stack to the app stack upon login. That way you don't have to worry about swiping back either, and you can program your back button to actually work, and not disable functionality.
– AnonymousSB
Nov 20 '18 at 9:49
can u provide a sample example for above
– Sreedhar L
Nov 26 '18 at 11:22
Here's a stripped down version of what I use. I'm using
redux
andredux-saga
. This particular snippet is from an app usingreact-navigation ^1.0.0-beta.15
– AnonymousSB
Nov 26 '18 at 11:44
how to load images from a resources folders like drawable/mipmap in react native app
– Sreedhar L
Nov 29 '18 at 6:59
You really should post that as a separate question. To the best of my knowledge you don't. Even if you could, that would be a very bad programming practice. Theoretically you could create a Native Module to do this, or maybe someone has already made one.
– AnonymousSB
Nov 29 '18 at 7:13