Closed
Description
I'm not sure whether this is as intended, or a problem with JavaScript, but I fiddled around with your example on facebook.github.io/react and tried this code:
var Timer = React.createClass({
getInitialState: function() {
return {secondsElapsed: 0};
},
tick: React.autoBind(function() {
this.setState({secondsElapsed: this.state.secondsElapsed + 0.1});
}),
componentDidMount: function() {
setInterval(this.tick, 100);
},
render: function() {
return React.DOM.div({},
'Seconds Elapsed: ' + this.state.secondsElapsed
);
}
});
React.renderComponent(Timer({}), mountNode);
The result comes out as 0.1, 0.2, ... as intended, but at some point the adding will give out numbers such as 0.30000000004 or 0.79999999999
Hope this explains well.
Hieu
Metadata
Metadata
Assignees
Labels
No labels