File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 99 "web" : " expo start --web"
1010 },
1111 "dependencies" : {
12+ "@react-native-community/hooks" : " ^3.0.0" ,
1213 "@react-navigation/native" : " ^6.1.1" ,
1314 "@react-navigation/native-stack" : " ^6.9.7" ,
1415 "expo" : " ~47.0.9" ,
Original file line number Diff line number Diff line change @@ -4,25 +4,21 @@ import { AnimatedScrollView } from '@kanelloc/react-native-animated-header-scrol
44import { data , isIOS } from '../utils' ;
55import { RefreshControl , StyleSheet } from 'react-native' ;
66import { SafeAreaView } from 'react-native-safe-area-context' ;
7+ import { useRefresh } from '@react-native-community/hooks' ;
78
8- const wait = ( timeout : any ) => {
9- return new Promise ( ( resolve ) => setTimeout ( resolve , timeout ) ) ;
9+ const fetch = ( ) => {
10+ return new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
1011} ;
1112
1213export const RefreshControlExample = ( ) => {
13- const [ refreshing , setRefreshing ] = React . useState ( false ) ;
14-
15- const onRefresh = React . useCallback ( ( ) => {
16- setRefreshing ( true ) ;
17- wait ( 2000 ) . then ( ( ) => setRefreshing ( false ) ) ;
18- } , [ ] ) ;
14+ const { isRefreshing, onRefresh } = useRefresh ( fetch ) ;
1915
2016 return (
2117 < SafeAreaView style = { styles . container } edges = { [ 'bottom' ] } >
2218 < AnimatedScrollView
2319 refreshControl = {
2420 < RefreshControl
25- refreshing = { refreshing }
21+ refreshing = { isRefreshing }
2622 onRefresh = { onRefresh }
2723 style = { styles . refresh }
2824 progressViewOffset = { 32 } // Add offset to position correctly progressView in iOS
Original file line number Diff line number Diff line change 17651765 prompts "^2.4.0"
17661766 semver "^6.3.0"
17671767
1768+ " @react-native-community/hooks@^3.0.0 " :
1769+ version "3.0.0"
1770+ resolved "https://registry.yarnpkg.com/@react-native-community/hooks/-/hooks-3.0.0.tgz#af5f2ca32eea59b792ce9e3d9a4cf0354f9b195f"
1771+ integrity sha512-g2OyxXHfwIytXUJitBR6Z/ISoOfp0WKx5FOv+NqJ/CrWjRDcTw6zXE5I1C9axfuh30kJqzWchVfCDrkzZYTxqg==
1772+
17681773" @react-native/assets@1.0.0 " :
17691774 version "1.0.0"
17701775 resolved "https://registry.yarnpkg.com/@react-native/assets/-/assets-1.0.0.tgz#c6f9bf63d274bafc8e970628de24986b30a55c8e"
You can’t perform that action at this time.
0 commit comments