Comments (5)
Fixed in 1.0.3, I have add ability to change state outside via value
prop.
from material-ui-datetimepicker.
Hi, seems that I should fix that from the picker side.
Will do that tomorrow and publish the release.
from material-ui-datetimepicker.
I've made a quick self-contained demo to show what I mean:
https://codesandbox.io/s/n91wn3vzm0
import React from 'react';
import { render } from 'react-dom';
import moment from 'moment';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import DateTimePicker from 'material-ui-datetimepicker';
import DatePickerDialog from 'material-ui/DatePicker/DatePickerDialog'
import TimePickerDialog from 'material-ui/TimePicker/TimePickerDialog';
class Demo extends React.Component {
state = {
dateTime: moment()
}
setDate(dateTime) {
this.setState({ dateTime })
}
updateTime() {
this.setState({ dateTime: moment().add(30, "minutes")})
alert("Time updated")
}
render() {
return (
<div>
<MuiThemeProvider>
<DateTimePicker
onChange={this.setDate.bind(this)}
defaultTime={this.state.dateTime}
DatePicker={DatePickerDialog}
TimePicker={TimePickerDialog}
/>
</MuiThemeProvider>
<button onClick={this.updateTime.bind(this)}>Add 30 minutes</button>
</div>
);
}
}
render(<Demo />, document.getElementById('root'));
from material-ui-datetimepicker.
I've hacked around this issue for now by abusing conditional rendering 😅:
forceRerender() {
this.setState({showPicker: false})
setTimeout(() => {
this.setState({showPicker: true})
}, 0)
}
// within render
{ this.state.showPicker && <DateTimePicker
onChange={this.setDate.bind(this)}
format='MMM DD, YYYY HH:mm'
timePickerDelay={50}
// ...
/>
}
from material-ui-datetimepicker.
Amazing, just in time for my app release. 😄
I've just updated and can confirm that setting the value
prop will update the Picker as expected.
Thanks a lot and especially for fixing this so fast! 👍
Kudos
from material-ui-datetimepicker.
Related Issues (20)
- Error type of props HOT 3
- Textfield Full width problem HOT 1
- defaultTime error HOT 1
- clearIcon works even after disabled the field HOT 3
- Warning: React does not recognize the `autoOk` HOT 1
- onChange doesn't fire HOT 10
- Request for the ability to turn off time HOT 1
- Setting initialDate still broken
- clearIcon still seems to render the functionality of the button
- Getting quirky display issue when clearing value from the field
- Add missing onDismiss property pass-through for TimePicker
- Changing the locale? HOT 1
- How can I set default date? HOT 2
- How can select only year
- The Textfield component within shouldn't allow key inputs
- Disable focus on click HOT 12
- Support floatingLabelText or hintText property HOT 2
- Warning in React 16 HOT 2
- error on importing. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui-datetimepicker.