/* @flow */ var ImageViewer = require('./imageViewer'); var React = require('react/addons'); type State = { photoIndex: number; inputText: string; } var App = React.createClass({ mixins: [React.addons.LinkedStateMixin], getInitialState: function(): State { return { photoIndex: 0, inputText: '1' } }, handleChange: function(addend) { var newIndex = this.state.photoIndex+addend, maxPhotos = 3; // clamp [0 thru maxPhotos-1] newIndex = Math.max(0, Math.min(maxPhotos-1, newIndex)); this.setState({ photoIndex: newIndex, inputText: newIndex+1 }) }, handleKeyPress: function(e) { if (e.key == 'Enter') { this.setState({ photoIndex: parseInt(this.state.inputText, 10)-1 }) } }, render: function () { return
Picture Purrfect
} }) React.render(, document.body);