DateTime.js | ●●●●● patch | view | raw | blame | history | |
example/viewModeChangeExample.js | ●●●●● patch | view | raw | blame | history |
DateTime.js
@@ -157,18 +157,22 @@ ; if ( nextProps.value !== this.props.value || formats.datetime !== this.getFormats( this.props ).datetime ){ formats.datetime !== this.getFormats( this.props ).datetime ) { update = this.getStateFromProps( nextProps ); } if ( update.open === undefined ){ if ( this.props.closeOnSelect && this.state.currentView !== 'time' ){ if ( update.open === undefined ) { if ( this.props.closeOnSelect && this.state.currentView !== 'time' ) { update.open = false; } else { update.open = this.state.open; } } if ( nextProps.viewMode !== this.props.viewMode ) { update.currentView = nextProps.viewMode; } this.setState( update ); }, example/viewModeChangeExample.js
New file @@ -0,0 +1,34 @@ var DateTime = require('../DateTime.js'); var React = require('react'); var ReactDOM = require('react-dom'); var moment = require('moment'); var Wrapper = React.createClass({ getInitialState: function() { return { viewMode: 'time' }; }, updateView: function(format) { console.log('changing viewMode to days'); this.setState({ viewMode: 'days' }); }, componentDidMount: function() { setTimeout(this.updateView, 3000); }, render: function() { console.log('Current viewmode: ' + this.state.viewMode); return React.createElement(DateTime, { viewMode: this.state.viewMode, defaultValue: moment() }); } }); ReactDOM.render( React.createElement(Wrapper), document.getElementById('datetime') );