Comments (2)
Can you maybe fix this issue. Guess thats not mutch work. Would help a lot!
from react-native-stopwatch-timer.
I'm aware that it is likely this project has been shelved or abandoned for the time being, but in case devs ever come back to this, I wanted to help and provide a suggestion for how to overhaul componentWillRecieveProps for the future.
Currently, the way time updating occurs is with the following function:
componentWillReceiveProps(newProps) {
if(newProps.start) {
this.start();
} else {
this.stop();
}
if(newProps.reset) {
this.reset(newProps.totalDuration);
}
}
As mentioned above by @JuliaCastillo , this could be resolved for now by changing it to UNSAFE_componentWillRecieveProps
,
or alternatively by overhauling the function completely and making use of componentDidUpdate
instead.
In limited testing I've done on my end with the timer
method, I've found that this works identically and doesn't cause issues:
componentDidUpdate(prevProps) {
if (this.props.start !== prevProps.start) {
if(this.props.start) {
this.start();
} else {
this.stop();
}
}
if (this.props.reset !== prevProps.reset) {
if(this.props.reset) {
this.reset(this.props.totalDuration);
}
}
}
Not a huge React or JS expert so it's possible this code block could be made better
from react-native-stopwatch-timer.
Related Issues (20)
- Change text style on setState HOT 1
- Set timer HOT 3
- Bug display, react-native v 0.53 HOT 3
- kinda ugly HOT 1
- Style Issue HOT 1
- timer minutes HOT 5
- How to use multiple Timers in FlatList HOT 1
- getting the time from the stopwatch with getTime HOT 3
- How to disable hours? HOT 8
- Memory leaks when component is unmounted HOT 1
- getMsecs slows down the counter HOT 1
- Modal disables start/pause button HOT 1
- GetTime method is undefined
- Stopwatch is pause. when app in background mode or lock device screen. HOT 1
- Stopwatch auto refresh at 23:00:00 - 24:00:00 why this happen android.
- Reset does not function correctly HOT 2
- iOS screen freezing completely when resume app from the background HOT 1
- Issue with stop and start fixed by this LINE 69 HOT 6
- Issue with stopwatch start and stop (Not resolved Properly)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-stopwatch-timer.