Search code examples
react-nativeframe-rate

react native how to get blink effect consistent


I need to have a consistent "blink" in very fast speeds, it works on slow speed

timer speed > 100

but when using timer speed < 50, I get some inconsistent blinking

https://youtu.be/qZAoTbVCW9E

so my question is, what is the maximum FPS blinking I could get? how to get the blinking consistent?

here my code for the basic blink

<View style={styles.container} backgroundColor = {this.state.torchStatus ? '#FF0000' : '#00FF00'}>

and the timer

  timer = () => {
let time = 100;

timer.setInterval(this, 'torch', 
() => this.setState({
  torchStatus:!this.state.torchStatus}, 
  ), 
  time);
}

Solution

  • React native render at 60fps.
    What you can try is setting your timer speed at 17 (1000 / 60 = 16.666 )