A simple react pull-to-refresh component with 0 dependencies. Its API design is similar to Ant Design Mobile, but it is more customizable and only 2kb after compression, suitable for both Mobile and Desktop.
npm install nextjs-pull-to-refreshifyA simple react pull-to-refresh component with 0 dependencies. Its API design is similar to Ant Design Mobile, but it is more customizable and only 2kb after compression, suitable for both Mobile and Desktop.
dependencies:
bash
$ npm i react-pull-to-refreshify
or
$ yarn add react-pull-to-refreshify
`
Usage
`tsx
function renderText(pullStatus, percent) {
switch (pullStatus) {
case "pulling":
return (
{Pull down }
{${percent.toFixed(0)}%}
);
case "canRelease":
return "Release";
case "refreshing":
return "Loading...";
case "complete":
return "Refresh succeed";
default:
return "";
}
}
const [refreshing, setRefreshing] = useState(false);
function handleRefresh() {
setRefreshing(true);
setTimeout(() => {
setRefreshing(false);
}, 2000);
}
refreshing={refreshing}
onRefresh={handleRefresh}
renderText={renderText}
>
{list.map((item, i) => (
{item}
))}
;
`
Examples
- Basic
- Max Height
- Load more
- animation 1
- animation 2
Props
`ts
type PullStatus =
| "normal"
| "pulling"
| "canRelease"
| "refreshing"
| "complete";
``