This file contains hidden or 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, { useState, useEffect } from "react"; | |
import { Dimensions, StyleSheet, Text, View } from "react-native"; | |
import * as Location from "expo-location"; | |
import MapView from "react-native-maps"; | |
export const MyMapComponent = () => { | |
const [location, setLocation] = useState(null); | |
const [errorMsg, setErrorMsg] = useState(null); | |
// Request access for location permissions and store them |
This file contains hidden or 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
function yourCustomFunctionName() { | |
XanoAuth.logout({ redirectTo: "SecretScreen" }); | |
// or, to reset without redirect: | |
// logout(); | |
} |
This file contains hidden or 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
async function yourCustomFunctionName() { | |
try { | |
await XanoAuth.login({ email, password }); | |
// Add your code here handling if successfull | |
// Ex: props.navigation.navigate("SecretScreen"); | |
} catch(err) { | |
// Add your code here handling if failed. | |
// Ex: alert(err.message); | |
} | |
} |
This file contains hidden or 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
React.useEffect(() => { | |
// No need to use this login screen, because it appears | |
// the user is already logged in. | |
if (XanoAuth.isAuthenticated) { | |
props.navigation.navigate("SecretScreen"); | |
} | |
}, []); |
This file contains hidden or 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
// If you have a screen named "Login": | |
XanoAuth.useProtectScreen({ redirectTo: "LoginScreen" }); |
This file contains hidden or 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 { useNavigation } from '@react-navigation/native'; | |
import * as GlobalVariableContext from "./config/GlobalVariableContext"; | |
/** | |
* Custom React Hook snippet for Xano (https://www.xano.com) authentication. | |
* | |
* Checkout Draftbit docs and community to learn more about using this snippet | |
* in Draftbit. |
This file contains hidden or 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 { Text, View, Button } from 'react-native'; | |
import * as GlobalVariableContext from './config/GlobalVariableContext'; | |
export const GlobalVariableComponent = () => { | |
const variables = GlobalVariableContext.useValues(); | |
const setVariable = GlobalVariableContext.useSetValue(); | |
return ( | |
<View> |
This file contains hidden or 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 { Text } from "react-native"; | |
import * as GlobalVariableContext from "./config/GlobalVariableContext"; | |
export const MyVariableDisplay = () => { | |
const variables = GlobalVariableContext.useValues(); | |
return <Text> { variables.myGlobal } </Text> | |
}; |
This file contains hidden or 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 } from "react-native"; | |
import * as GlobalVariableContext from "./config/GlobalVariableContext"; | |
export const MyVariableSetter = () => { | |
const setGlobalVariable = GlobalVariableContext.useSetValue(); | |
const myNewValue = { key: "mySettableGlobal", value: "new value" }; | |
return ( |