Drop-in RefreshControl component for web
npm i react-native-web-refresh-control
You don't need to change anything else
You will need to configure webpack to parse JSX in node_modules/react-native-web-refresh-control
.
- Eject from
react-scripts
withnpm run eject
. - Modify the main
babel-loader
module inconfig/webpack.config.js
.- Replace
include: paths.appSrc,
withinclude: [paths.appSrc, /node_modules\/react-native-web-refresh-control/],
- Replace
https://snack.expo.io/@niciusb/refreshcontrol-example
react-native-web-refresh-control
exports two properties:
-
patchFlatListProps
is a function that you'll want to call at some point, while loading your app. It replaces the default value of the refreshControl prop ofFlatList
-
RefreshControl
can be used to easily giveScrollView
a pull-to-refresh functionality, just like theRefreshControl
exported from react-native. However, if you used theRefreshControl
from react-native, it would not work on the web. To see how to do this, check out this snack: https://snack.expo.io/@niciusb/refreshcontrol-example
// index.js
import { patchFlatListProps } from 'react-native-web-refresh-control'
import App from './App'
patchFlatListProps()
registerRootComponent(App)