-
Notifications
You must be signed in to change notification settings - Fork 25k
Description
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
OS: Linux 4.4
Node: 6.9.4
Yarn: Not Found
npm: 3.10.10
Watchman: Not Found
Packages: (wanted => installed)
react-native: 0.48.4 => 0.48.4
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
Target Platform: Android 7 (SDK version 25)
Steps to Reproduce
Create a simple React component that invokes requestAnimationFrame once, stores the time parameter in state, and renders the result:
import React from 'react';
import {
AppRegistry,
StyleSheet,
View,
Text
} from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
})
class App extends React.Component {
constructor() {
super();
this.state = {
time: 0,
};
requestAnimationFrame(time => (
this.setState({
time,
})
));
}
render() {
const { showProgressBar } = this.state;
return (
<View style={styles.container}>
<Text>{this.state.time}</Text>
</View>
);
}
}
AppRegistry.registerComponent('App', () => App);Expected Behavior
The time parameter should be the time elapsed since the "page" "loaded" (navigated to current view or activity?) as is the case in Chrome and Firefox (this value should be performance.now(), according to MDN.
Actual Behavior
The time parameter resolves to the current Unix timestamp (i.e. Date.now()).
Reproducible Demo
https://github.com/jamesseanwright/react-native-requestanimationframe-bug
I'd be happy to submit a PR to fix this, but I'm unsure of how this project versions breaking changes. I can work around this issue, but it would be great to achieve parity with the browser API so that I can avoid platform-specific hacks.
Let me know your thoughts.
Cheers,
James

