1.0.9 • Published 6 years ago

react-refresher v1.0.9

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

React Refresher

A pull-to-refresh component for react

Installation

npm:

npm install --save react-refresher

yarn:

yarn add react-refresher

Import

ES6

import Refresher from 'react-refresher'

ES5

var Refresher = require('react-refresher').default

Usage

class MyList extends React.Component {
  constructor (props, ctx) {
    super(props, ctx)
    ...

    this.onRefresh = this.onRefresh.bind(this)
    this.state = {
      ...
      articles: []
    }
  }
  ...
  
  onRefresh () {
    return fetch('http://sample.api/article')
      .then(res => res.json())
      .then(articles => this.setState({ articles }))
  }

  render () {
    return (
      <Refresher onRefresh={this.onRefresh}>
        ...
      </Refresher>
    )
  }
}

API

PropTypeRequired?DefaultNotes
onRefresh() => PromiseYesThe promise should resolve when the re-fetching is complete, or reject on error
loadingHeightanyNo70Can be any value valid for the height style prop in React
animationTimenumberNo500Length of the refresher hiding animation, in milliseconds
classNameStringNo''This is applied to the entire refresher area (including content area)
downArrowJSX.ElementNo'↓'Can also just be a string
upArrowJSX.ElementNo'↑'Can also just be a string
errorIconJSX.ElementNo'✖'Can also just be a string
successIconJSX.ElementNo'✔'Can also just be a string
spinnerJSX.ElementNo'Loading...'Can also just be a string
refreshBackgroundStringNo'none'Can be any CSS value that is appropriate for the background prop
refreshColorStringNo'currentColor'Can be any CSS value that is appropriate for the color prop

Advanced usage

Internal CSS classes

CSS classUsed for
pull-to-refreshThe entire refresher, around the loader and content
loaderThe loader, used to render the up arrow, down arrow, spinner, success, and failure icons
contentThe content area, where the children of the refresher are rendered
1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago