Skip to content

Instantly share code, notes, and snippets.

View Yassir4's full-sized avatar
🎯
Focusing

Hartani Yassir Yassir4

🎯
Focusing
View GitHub Profile
@Yassir4
Yassir4 / styles.js
Created August 4, 2019 18:47
ModalScreen/styles.js
// ModalScreen/styles.js
import {StyleSheet} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'skyblue',
},
@Yassir4
Yassir4 / index.js
Created August 13, 2019 11:36
export navigation functions Navigation/index.js
export const pushScreen = props => {
const { componentId } = props;
Navigation.push(componentId, {
component: {
name: 'PushedScreen',
},
});
};
export const openModal = () => {
export const pushScreen = props => {
const { componentId } = props;
Navigation.push(componentId, {
component: {
name: 'PushedScreen',
},
});
};
export const openModal = () => {
@Yassir4
Yassir4 / resetXcode.sh
Created October 9, 2019 19:05 — forked from maciekish/resetXcode.sh
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/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
@Yassir4
Yassir4 / index.js
Created September 15, 2020 07:56
Repositories
const { data, error, loading, fetchMore } = useQuery(REPOSITORIES_QUERY, {
variables: { first: 15 },
})
@Yassir4
Yassir4 / index.js
Last active September 15, 2020 08:00
Repositoires
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 / index.js
Created September 15, 2020 08:01
Repositories
const handleOnEndReached = () => {
if (data.organization.repositories.pageInfo.hasNextPage)
return fetchMore({
variables: {
after: data.organization.repositories.pageInfo.endCursor,
first: 15,
},
updateQuery: onUpdate,
})
}
@Yassir4
Yassir4 / index.js
Created September 15, 2020 08:08
Repositories
/// ...
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, {
import { NetworkStatus } from '@apollo/client'
.
.
.
const { data, error, loading, fetchMore, refetch, networkStatus } = useQuery(REPOSITORIES_QUERY, {
variables: { first: 15 },
notifyOnNetworkStatusChange: true,
})
@Yassir4
Yassir4 / index.js
Created September 15, 2020 08:12
Repositories
// 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>
)