npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-web-refresh-control

v1.1.2

Published

An implementation of React Native's RefreshControl for web, since react-native-web currently does not provide one

Downloads

5,579

Readme

react-native-web-refresh-control NPM Version

Drop-in RefreshControl component for web

Installation and Configuration

npm i react-native-web-refresh-control

If you're using Expo

You can go ahead and use the package!

If you're NOT using Expo

You will need to configure webpack to parse JSX in node_modules/react-native-web-refresh-control.

  1. Eject from react-scripts with npm run eject. Make sure to know what ejecting is before doing it.
  2. Modify the main babel-loader module in config/webpack.config.js.
    • Replace include: paths.appSrc, with include: [paths.appSrc, /node_modules\/react-native-web-refresh-control/],

Usage

react-native-web-refresh-control exports two properties:

  • patchFlatListProps is a function that you can call at some point, while your app is loading. It replaces the default value of the refreshControl prop of FlatList

  • RefreshControl can be used to easily give ScrollView a pull-to-refresh functionality, just like the RefreshControl exported from react-native. However, if you used the RefreshControl 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

Example of RefreshControl

https://snack.expo.io/@niciusb/refreshcontrol-example

import { RefreshControl } from 'react-native-web-refresh-control'


<ScrollView
   refreshControl={
      <RefreshControl refreshing={refreshing} onRefresh={reloadLines} />
   }
>
   <Text>This scrollview will have pull-to-refresh functionality on the web</Text>
</ScrollView>

Example of patchFlatListProps

// index.js
import { patchFlatListProps } from 'react-native-web-refresh-control'

import App from './App'

patchFlatListProps()
registerRootComponent(App)

Customize flat list refresh control for web

  • patchFlatListProps takes optional options to customize the refresh control:
  • To customize refresh control for iOS and Android, please see RefreshControl API

| option | Type | Description | default | |------------|---------------------|------------------------------------------------------------------------------------------|----------------------------------| | colors | array | If tintColor is not defined, it uses the first color in the array for refresh indicator. | | | enabled | boolean | Whether the pull to refresh functionality is enabled. | true | | size | RefreshControl.SIZE | Size of the refresh indicator. | RefreshLayoutConsts.SIZE.DEFAULT | | tintColor | color | The color of the refresh indicator. | | | title | string | The title displayed under the refresh indicator. | | | titleColor | color | The color of the refresh indicator title. | | | |

  • Example
// index.js
import { patchFlatListProps } from 'react-native-web-refresh-control'

import App from './App'

// make refresh control red
patchFlatListProps({tintColor: 'red'})
registerRootComponent(App)