React component for managing time expiration
npm install react-expireReact component for managing time expiration.
Sometimes, we need to show something, and after, remove this thing. The simpliest case - notification that must disappear after some time.
```with NPM
npm install react-expire --saveor YARN
yarn install react-expire
react-expire component accepts such props:onExpire
- until Lifetime in milliseconds. If set 0 - this means that widget will never expire. When widget will expire - property will be triggered.onExpire
- 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 - 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
``
2. As render-prop
``
{(expired) => (
expired ? 'Expired' : 'Not yet expired'
)}
NOTE: You can use together render-prop pattern and callback function.
``
npm run build
```
npm run example