Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/bboydflo/use-value-after

dead simple react hook to get the next value from an array after a specific delay
https://github.com/bboydflo/use-value-after

Last synced: about 1 month ago
JSON representation

dead simple react hook to get the next value from an array after a specific delay

Awesome Lists containing this project

README

        

Welcome to use-value-after 👋




Version


Documentation


Twitter: CosminOnciu

> react hook to use values from an array after delay. when reaching the end of the array it will start from the beginning

### 🏠 [Homepage](https://github.com/bboydflo/use-value-after)

## Install

```sh
npm install
```

## Usage

This hook comes in handy when testing edge cases for a React component by generating a new set of props after a specific delay

```js
import React from 'react'
import ReactDOM from 'react-dom'
import { useValueAfter } from 'use-value-after'

const TestComponent = (props) => {
return (


{props.title}


{props.text}



)
}

const updatePropsAfterMs = 1000
const testComponentProps = [
{title: '', text: ''},
{title: '', text: 'No title'},
{title: 'Short title', text: ''},
{title: 'Short title', text: 'Really small paragraph'}
]

const App = () => {
const props = useValueAfter(testComponentProps, updatePropsAfterMs)
return (




)
}

ReactDOM.render(, document.getElementById('root'))
```

## CodeSandbox Demo

For a demo [take a look here](https://codesandbox.io/s/use-value-after-demo-ov7lz)

## Author

👤 **Florin Cosmin Onciu**

* Twitter: [@CosminOnciu](https://twitter.com/CosminOnciu)
* Github: [@bboydflo](https://github.com/bboydflo)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/bboydflo/use-value-after/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).

## Show your support

Give a ⭐️ if this project helped you!

***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_