-3
Material UI Libraryで日付/時刻ピッカーをプログラムで閉じるには?Material UI Libraryで日付/時刻ピッカーをプログラムで閉じる?
Material UI Libraryで日付/時刻ピッカーをプログラムで閉じるには?Material UI Libraryで日付/時刻ピッカーをプログラムで閉じる?
import React from 'react';
import DatePickerDialog from 'material-ui/DatePicker/DatePickerDialog';
export default class SomeComponent extends React.Component {
constructor(props, context) {
super(props, context);
this.closeDatePicker = this.closeDatePicker.bind(this);
this.openDatePicker = this.openDatePicker.bind(this);
}
closeDatePicker() {
this.datePicker.dismiss();
}
openDatePicker() {
this.datePicker.show();
}
render() {
return (
<div>
<button onClick={this.openDatePicker}>Open</button>
<button onClick={this.closeDatePicker}>Close</button>
<DatePickerDialog ref={ref => this.datePicker = ref} />
</div>
);
}
}
私はあなたの問題のために任意のコードやコンテキスト(これまでのところなど、あなたの試みを)共有していないので、あなたがdownvotesを得たと仮定します。試してみませんでしたが、似たような質問に対するこの回答はあなたのために面白いかもしれません。https://stackoverflow.com/a/39619803/4763083 – jonahe
次回はコードを書いていきます。ありがとう –