Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Back Button Functionality #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Vigneshpillai19
Copy link

Default behaviour of Back button will be exiting the App and User can pass his own function as a prop for custom behaviour of the component.

@vikrantnegi
Copy link
Owner

Thanks for the PR. I'll test it out before merging.

@Vigneshpillai19
Copy link
Author

Okay Thanks

@Vigneshpillai19
Copy link
Author

Have you checked my Code?
Is it working properly?

src/index.js Outdated
@@ -12,6 +12,7 @@ export default class AnimatedLoader extends React.PureComponent {
animationStyle: {},
speed: 1,
loop: true,
backButtonPress: () => Backhandler.exitApp(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Backhandler' is not defined

Typo error.

@@ -63,7 +65,7 @@ export default class AnimatedLoader extends React.PureComponent {
visible={visible}
animationType={animationType}
supportedOrientations={['portrait']}
onRequestClose={() => {}}
onRequestClose={backButtonPress}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'backButtonPress' is not defined.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backButtonPress is defined

@vikrantnegi
Copy link
Owner

vikrantnegi commented Jul 13, 2020

@Vigneshpillai19

Please check the comments I've made. and update the PR. Also, make sure the code works properly on both iOS and Android. It doesn't seems to working properly.

Thanks.

@Vigneshpillai19
Copy link
Author

Thanks for Checking my Code and informing me about the mistake.
There was a small spelling mistake in BackHandler function name which I Corrected now.
This functionality of exiting App will work for Android only as BackHandler works for only Android and for IOS we have to install (react-native-exit-app) module and add it in gradle file so for IOS I have not added any default behaviour.
Both Android and IOS users can pass customised function as a prop (backButtonPress) which will get executed on pressing the back button. So I guess this can work on both the Platforms but default behaviour of exiting App will work only on Android.

Thank You for giving your time in checking my Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants