Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanitsharma/react-suspender
React component that forcefully suspends the the component tree.
https://github.com/kanitsharma/react-suspender
javascript reactjs suspense
Last synced: 20 days ago
JSON representation
React component that forcefully suspends the the component tree.
- Host: GitHub
- URL: https://github.com/kanitsharma/react-suspender
- Owner: kanitsharma
- Created: 2019-08-14T07:20:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T21:33:37.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T22:54:14.407Z (about 1 month ago)
- Topics: javascript, reactjs, suspense
- Language: JavaScript
- Homepage:
- Size: 1.26 MB
- Stars: 20
- Watchers: 1
- Forks: 0
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-suspender
React component that forcefully suspends the component tree.
>
[![NPM](https://img.shields.io/npm/v/react-suspender.svg)](https://www.npmjs.com/package/react-suspender) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
## Install
```bash
npm install --save react-suspender
```## Usage
```jsx
import React, { Component, Suspense } from 'react'import Suspender from 'react-suspender'
class SuspendExample extends Component {
render () {
return (
Suspended}>
)
}
}
```Another example, you can suspend your component tree while data fetching.
```jsx
import React, { Component, Suspense } from 'react'import Suspend from 'react-suspender'
function SuspendExample () {
const [ dataLoaded, setDataLoaded ] = React.useState(false);// Fetch Data
React.useEffect(() => {
const timer = setTimeout(() => {
setDataLoaded(true);
}, 1000);return () => clearTimeout(timer);
});return (
Loading...}>
API data loaded !!!
)
}
```## Props
- suspend : bool
## License
MIT © [kanitsharma](https://github.com/kanitsharma)