An open API service indexing awesome lists of open source software.

https://github.com/d8corp/react-def

Deferring of the components rendering
https://github.com/d8corp/react-def

Last synced: about 1 year ago
JSON representation

Deferring of the components rendering

Awesome Lists containing this project

README

          

# react-def
[![NPM](https://img.shields.io/npm/v/react-def.svg)](https://www.npmjs.com/package/react-def)
[![NPM](https://img.shields.io/npm/dm/react-def.svg)](https://www.npmjs.com/package/react-def)
[![license](https://img.shields.io/npm/l/html-classes)](https://github.com/d8corp/react-def/blob/master/LICENSE)

Use the component when DOM changes or component rendering take a lot of time.
## Installation
```bash
npm i react-def
# or
yarn add react-def
```
## Using
The best way of using the component is to do it with elements that show self only on hover.
The rendering of the components starts working only when the whole app will be rendered and displayed.
Then `Def` components will render one by one as quickly as we can have `60fps`.
```typescript jsx
import Def from 'react-def'
const TEN = [...new Array(10)]

const Throttling = ({value = 10, children}) => {
const end = Date.now() + value
while (Date.now() < end) {
continue
}
return children
}

const SimpleComponent = () => (


{TEN.map((v, i) => (

{TEN.map((v, j) => (

({i}.{j})

))}

))}

)

const DefComponent = () => (


{TEN.map((v, i) => (


{TEN.map((v, j) => (

({i}.{j})

))}


))}

)
```
Try to use the `SimpleComponent` and the `DefComponent` and you see the difference.
Also, you can provide property of the `placeholder` to show something wile it's rendering.
```typescript jsx
const DefComponentPredefine = () => (

{TEN.map((v, i) => (


{TEN.map((v, j) => (

({i}.{j})

))}


))}

)
```
If you wanna defer the rendering only once use `once` property.
```typescript jsx
const DefComponentPredefine = () => (

{TEN.map((v, i) => (


{TEN.map((v, j) => (

({i}.{j})

))}


))}

)
```
## Issues
If you find a bug, please file an issue on [GitHub](https://github.com/d8corp/react-def/issues).