View apollo.ts
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
//Declare your endpoints | |
const endpoint1 = new HttpLink({ | |
uri: 'https://api.hashnode.com/graphql', | |
... | |
}) | |
const endpoint2 = new HttpLink({ | |
uri: 'endpoint2/graphql', | |
... | |
}) |
View useKeyboardHeight.js
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 { useState, useEffect } from "react"; | |
import { Keyboard, Platform } from "react-native"; | |
const isIOS = Platform.OS === "ios"; | |
const useKeyboardHeight = () => { | |
const [keyboardHeight, setKeyboardHeight] = useState(0); | |
const handleKeyboardDidShow = (e) => { | |
setKeyboardHeight(e.endCoordinates.height); | |
}; |
View Home.js
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
<Menu trigger={<Text>press here</Text>}> | |
<MenuItem | |
text={"Title"} | |
onPress={() => alert("option pressed")} | |
/> | |
<MenuItem | |
text={"Recently Added"} | |
onPress={() => alert("option pressed")} | |
/> | |
<MenuItem |
View App.js
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
function App() { | |
return ( | |
<NavigationContainer> | |
<PortalProvider> | |
{/* view wrapper to fix the menu display in android */} | |
<View style={{flex: 1}}> | |
{/* our menu portal Host */} | |
<PortalHost name="menu" /> | |
<Stack.Navigator> | |
<Stack.Screen name="Home" component={HomeScreen} /> |
View index.js
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
// add this | |
const refreshing = networkStatus === NetworkStatus.refetch | |
// prevent the loading indicator from appearing while refreshing | |
if (loading && repositories.length === 0 && !refreshing) | |
return ( | |
<View style={styles.loading}> | |
<ActivityIndicator size="large" color="rgb(0, 122, 255)" /> | |
</View> | |
) |
View index.js
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 { NetworkStatus } from '@apollo/client' | |
. | |
. | |
. | |
const { data, error, loading, fetchMore, refetch, networkStatus } = useQuery(REPOSITORIES_QUERY, { | |
variables: { first: 15 }, | |
notifyOnNetworkStatusChange: true, | |
}) |
View index.js
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
/// ... | |
const onUpdate = (prev, { fetchMoreResult }) => { | |
if (!fetchMoreResult) return prev | |
const { pageInfo } = fetchMoreResult.organization.repositories | |
const nodes = [ | |
...prev.organization.repositories.nodes, | |
...fetchMoreResult.organization.repositories.nodes, | |
] | |
return Object.assign({}, prev, { |
NewerOlder