Last active
February 15, 2020 09:03
-
-
Save shirohana/b648bb1f8bea9294302fd0d085bb0750 to your computer and use it in GitHub Desktop.
React Navigation Lock Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Button, View } from 'react-native' | |
import useNavigateLock from '~hooks/use-navigate-lock' | |
const Home = ({ navigation }) => { | |
const lock = useNavigateLock() | |
const goSettings = () => lock() && navigation.push('Settings') | |
const goProfile = () => { | |
if (lock()) { | |
const params = { name: 'Hana' } | |
navigation.push('Profile', params) | |
} | |
} | |
return ( | |
<View> | |
<Button title="pushSettings" onPress={goSettings} /> | |
<Button title="pushProfile" onPress={goProfile} /> | |
</View> | |
) | |
} | |
export default Home |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment