reactjs / react-timer-mixin Goto Github PK
View Code? Open in Web Editor NEWTimerMixin provides timer functions for executing code in the future that are safely cleaned up when the component unmounts
License: MIT License
TimerMixin provides timer functions for executing code in the future that are safely cleaned up when the component unmounts
License: MIT License
Embed React Native inside Native Apps, install React Native by using CocoaPods. It works well, but when I add " var TimerMixin = require('react-timer-mixin'); ",it came out
Requiring unknown module "react-timer-mixin".
I exec�uted " npm install react-timer-mixin " ,but it didn't work.
Appears not to work properly, perhaps because used as a @mixin() ?
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the undefined component.
warning @ warning.js?8a56:44
getInternalInstanceReadyForUpdate @ ReactUpdateQueue.js?fd2c:45
ReactUpdateQueue.enqueueSetState @ ReactUpdateQueue.js?fd2c:192
ReactComponent.setState @ ReactComponent.js?702a:67
_handleDismiss @ AlertBanner.js?c408:195
(anonymous function) @ TimerMixin.js?fbdb:18
.
import { mixin } from 'core-decorators'
import TimerMixin from 'react-timer-mixin'
@mixin(TimerMixin)
class AlertBanner {
render () {
this._setupDismissTimer()
...
}
_setupDismissTimer () {
let theTimer = this._dismissTimer
if (this.state.autoDismiss
&& this._isShowing(this.state.transition)) {
if (!theTimer) {
theTimer = this.setTimeout(
this._handleDismiss
, TIMEOUT)
}
}
else {
this._clearDismissTimer()
}
this._dismissTimer = theTimer
}
@autoBind
_handleMouseEnter () {
this._clearDismissTimer()
}
@autoBind
_handleMouseLeave () {
this._setupDismissTimer()
}
_clearDismissTimer () {
const timer = this._dismissTimer
this._dismissTimer = void 0
if (timer) {
this.clearTimeout(timer)
}
}
}
I have to add this method to prevent an error, but I thought that was the point of this mixin to not have to clear any timers before we unmount.
componentWillUnmount() {
this._clearDismissTimer()
}
Can't you just use a private variable on the component for your timers, and then use the lifecycle method, componentWillUnmount
, to clear appropriate "timeouts" and "intervals"?
This mixin is uses more power than it needs to. This use case could be solved simply by using a documented & official lifecycle method.
hai i am using this module for pause and reset time but i am struggling that how to pause the timer,stop the timer,reset the timer, here i am attaching the image of the view
plaese help me how to done i used
TimerMixin.setTimeout(
() => { console.log('I do not leak!'); },
5000
);
but timer not stop,help me that how to pause the timer
To be more consistent with the React Native docs is it possible to provide a ES6 Class syntax of this in the documentation?
https://facebook.github.io/react-native/docs/timers.html#timermixin
thank you
Using this within React Native
As the title says, I'm having problems using this with server rendering.
I'm not using the mixin on the server, just requiring it.
It throws:
[ReferenceError: cancelAnimationFrame is not defined]
Right now mixins are not supported in react component that follow es6 class syntax.
Should we be writing a timermixin that can be extended by a react component with class syntax or can we use the current mixin as a base class?
See title please
Last year, Facebook actively dropped the patent grant from e.g. React. Unfortunately, this package still contains it, which raises the alarms we have set up.
Would it be possible to drop the patent grant?
Is this project still useful.
it hasn't be updated in the last two year.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.