Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
react-pullload
Advanced tools
Refreshing and Loading more component for react.
pullLoad is another refreshing and loading more lib without react, support require.js to load lib.
demo1 use ReactPullLoad root DOM as container
demo2 use ReactPullLoad root DOM as container
demo3 use document.body as container, and config UI component (HeadNode and FooterNode).
demo4 forbidden pull refresh
Support Typescript
npm install --save react-pullload
import ReactPullLoad, { STATS } from "react-pullload";
import "node_modules/react-pullload/dist/ReactPullLoad.css";
export class App extends Component {
constructor() {
super();
this.state = {
hasMore: true,
data: cData,
action: STATS.init,
index: loadMoreLimitNum //loading more test time limit
};
}
handleAction = action => {
console.info(action, this.state.action, action === this.state.action);
//new action must do not equel to old action
if (action === this.state.action) {
return false;
}
if (action === STATS.refreshing) {
this.handRefreshing();
} else if (action === STATS.loading) {
this.handLoadMore();
} else {
//DO NOT modify below code
this.setState({
action: action
});
}
};
handRefreshing = () => {
if (STATS.refreshing === this.state.action) {
return false;
}
setTimeout(() => {
//refreshing complete
this.setState({
data: cData,
hasMore: true,
action: STATS.refreshed,
index: loadMoreLimitNum
});
}, 3000);
this.setState({
action: STATS.refreshing
});
};
handLoadMore = () => {
if (STATS.loading === this.state.action) {
return false;
}
//无更多内容则不执行后面逻辑
if (!this.state.hasMore) {
return;
}
setTimeout(() => {
if (this.state.index === 0) {
this.setState({
action: STATS.reset,
hasMore: false
});
} else {
this.setState({
data: [...this.state.data, cData[0], cData[0]],
action: STATS.reset,
index: this.state.index - 1
});
}
}, 3000);
this.setState({
action: STATS.loading
});
};
render() {
const { data, hasMore } = this.state;
const fixHeaderStyle = {
position: "fixed",
width: "100%",
height: "50px",
color: "#fff",
lineHeight: "50px",
backgroundColor: "#e24f37",
left: 0,
top: 0,
textAlign: "center",
zIndex: 1
};
return (
<div>
<div style={fixHeaderStyle}>fixed header</div>
<ReactPullLoad
downEnough={150}
action={this.state.action}
handleAction={this.handleAction}
hasMore={hasMore}
style={{ paddingTop: 50 }}
distanceBottom={1000}
>
<ul className="test-ul">
<button onClick={this.handRefreshing}>refreshing</button>
<button onClick={this.handLoadMore}>loading more</button>
{data.map((str, index) => {
return (
<li key={index}>
<img src={str} alt="" />
</li>
);
})}
</ul>
</ReactPullLoad>
</div>
);
}
}
Property | Description | Type | default | Remarks |
---|---|---|---|---|
action | sync component status | string | isRequired | |
handleAction | handle status | func | isRequired | |
hasMore | flag for are there any more content to load | bool | false | |
downEnough | how long distance is enough to refreshing | num | 100 | use px as unit |
distanceBottom | current position is apart from bottom | num | 100 | use px as unit |
isBlockContainer | set root dom as container | bool | false | |
HeadNode | custom header UI compoent | any | ReactPullLoad HeadNode | must be a react component |
FooterNode | custom footer UI compoent | any | ReactPullLoad FooterNode | must be a react component |
Remarks: ReactPullLoad support set root dom className and style.
Property | Value | root className | explain |
---|---|---|---|
init | '' | component initial status | |
pulling | 'pulling' | state-pulling | pull status |
enough | 'pulling enough' | state-pulling.enough | pull down enough status |
refreshing | 'refreshing' | state-refreshing | refreshing status fetch data |
refreshed | 'refreshed' | state-refreshed | refreshed |
reset | 'reset' | state-reset | reset status |
loading | 'loading' | state-loading | fetching data |
init/reset -> pulling -> enough -> refreshing -> refreshed -> reset
init/reset -> pulling -> reset
init/reset -> loading -> reset
Please refer to the default HeadNode and FooterNode components
Or refer to demo3, show different dom style through compare props loaderState width STATS.
MIT
FAQs
React compopnent pull down refresh and pull up load more
The npm package react-pullload receives a total of 25 weekly downloads. As such, react-pullload popularity was classified as not popular.
We found that react-pullload demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.