Exciting news!Announcing our $4.6M Series Seed. Learn more
Socket
LoveBlogFAQ
Install
Log in

react-expire

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Issues
File Explorer

Advanced tools

react-expire

React component for managing time expiration

    1.0.2latest

Version published
Maintainers
1
Yearly downloads
6,007
increased by30.39%

Weekly downloads

Changelog

Source

1.0.2 / 2019-12-23

  • Call onExpire after state changing to prevent worning if component will unmount

Readme

Source

react-expire

React component for managing time expiration.

Why

Sometimes, we need to show something, and after, remove this thing. The simpliest case - notification that must disappear after some time.

Installation

# with NPM npm install react-expire --save # or YARN yarn install react-expire

How to use

react-expire component accepts such props:

  • until Lifetime in milliseconds. If set 0 - this means that widget will never expire. When widget will expire - onExpire property will be triggered.
  • onExpire Callback, that will be called when 'until' prop countdown will finish.
  • id Optional property. Used as identifier of "what" was expired. Usefull if you have parent component that renders "list" of "expirable" components, and you need to identify them in some way. If this props isn't - onExpire will be called without any params.
  • children Nothing, node or function (if you want to use it as render-prop. See examples below)

You can use this component in different ways:

  1. As component with(out) children that passes expire event in parent component via callback

    <Expire until={2000} id={1} onExpire={someParentComponentHandler}> <ChildComponent /> </Expire>
  2. As render-prop

    <Expire until={2000}> {(expired) => ( expired ? 'Expired' : 'Not yet expired' )} </Expire>

NOTE: You can use together render-prop pattern and callback function.

How to build

npm run build

How to run examples

npm run example

FAQs

What is react-expire?

React component for managing time expiration

Is react-expire popular?

The npm package react-expire receives a total of 87 weekly downloads. As such, react-expire popularity was classified as not popular.

Is react-expire well maintained?

We found that react-expire demonstrated a not healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.

Last updated on 23 Dec 2019
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc