Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Hartani Yassir Yassir4

🎯
Focusing
View GitHub Profile
View index.js
// 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
import { NetworkStatus } from '@apollo/client'
.
.
.
const { data, error, loading, fetchMore, refetch, networkStatus } = useQuery(REPOSITORIES_QUERY, {
variables: { first: 15 },
notifyOnNetworkStatusChange: true,
})
View index.js
/// ...
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, {
View index.js
const handleOnEndReached = () => {
if (data.organization.repositories.pageInfo.hasNextPage)
return fetchMore({
variables: {
after: data.organization.repositories.pageInfo.endCursor,
first: 15,
},
updateQuery: onUpdate,
})
}
View index.js
const { data, error, loading, fetchMore } = useQuery(REPOSITORIES_QUERY, {
variables: { first: 15 },
})
@Yassir4
Yassir4 / index.js
Last active Sep 15, 2020
Repositoires
View index.js
import React from 'react'
import { Text, SafeAreaView, View, FlatList, ActivityIndicator } from 'react-native'
import { useQuery, gql } from '@apollo/client'
import RepositoryItem from './components/RepositoryItem'
import styles from './styles'
const REPOSITORIES_QUERY = gql`
query($first: Int!) {
organization(login: "facebook") {
repositories(first: $first) {
@Yassir4
Yassir4 / resetXcode.sh
Created Oct 9, 2019 — forked from maciekish/resetXcode.sh
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
View resetXcode.sh
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
View index.js
export const pushScreen = props => {
const { componentId } = props;
Navigation.push(componentId, {
component: {
name: 'PushedScreen',
},
});
};
export const openModal = () => {
@Yassir4
Yassir4 / index.js
Created Aug 13, 2019
export navigation functions Navigation/index.js
View index.js
export const pushScreen = props => {
const { componentId } = props;
Navigation.push(componentId, {
component: {
name: 'PushedScreen',
},
});
};
export const openModal = () => {
@Yassir4
Yassir4 / styles.js
Created Aug 4, 2019
ModalScreen/styles.js
View styles.js
// ModalScreen/styles.js
import {StyleSheet} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'skyblue',
},
You can’t perform that action at this time.