React Native Webview — Pull Down to Refresh. Android_iOS _ by Zubyrbutt _ Medium
React Native Webview — Pull Down to Refresh. Android_iOS _ by Zubyrbutt _ Medium
Search
Listen Share
This is my main component. WebContainer.tsx
//WebContainer.tsx
WebViewNavigation,
} from 'react-native-webview';
import { TWebContainer } from './constraints';
import { useCustomTheme } from 'app/hooks/useCustomTheme';
import styles from './styles';
React.useEffect(() => {
if (refreshing) {
triggerRefresh();
}
}, [refreshing]);
return (
<View style={styles.screen}>
<ScrollView style={{}}
contentContainerStyle={{ flex: 1 }}
refreshControl={
<RefreshControl
refreshing={refreshing}
enabled={refresherEnabled}
onRefresh={() => {
triggerRefresh();
webViewRef?.current?.reload(); // Use optional chaining
}}
/>
}>
<RNWebView
onScroll={handleScroll}
ref={webViewRef}
scalesPageToFit
javaScriptEnabled={true}
domStorageEnabled={true}
setSupportMultipleWindows={false}
pullToRefreshEnabled={true}
cacheEnabled={props.cacheEnabled}
cacheMode="LOAD_DEFAULT"
source={{ uri: url }}
startInLoadingState={true}
renderLoading={Spinner}
onError={onLoadingError}
onHttpError={handleHttpError}
onNavigationStateChange={onNavigationStateChange}
/>
</ScrollView>
</View>
);
};
After a long time researching how to achieve this. use this component and leave a
comment if I improve this component.
Follow
Written by Zubyrbutt
2 Followers · 5 Following
Responses (1)
Respond
Stéphane Soler
5 months ago
Reply
Lists
Staff picks
786 stories · 1498 saves
Self-Improvement 101
20 stories · 3129 saves
Productivity 101
20 stories · 2646 saves
Sep 18 5.6K 78
The Expert Developer
Nov 29 200
Rutikpanchal
Building a Robust Form in React Native with React Hook Form and Zod for
Validation
Leveraging React Hook Form and Zod to Create Efficient and Scalable Form Validation in React
Native
Sep 11 4
Idrak Mirzayev
Oct 24 75