Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save colleenDunlap/d6c4d04aa034c59604b9d05eb10d2dd5 to your computer and use it in GitHub Desktop.
Save colleenDunlap/d6c4d04aa034c59604b9d05eb10d2dd5 to your computer and use it in GitHub Desktop.
Datepicker Forecast On A Day
<div id="app"></app>
class Application extends React.Component {
constructor(props){
super(props)
this.state = {date: moment()};
this.dateChanged = this.dateChanged.bind(this);
}
dateChanged(d){
this.setState({date: d});
}
render() {
return (
<div>
<DatePicker selected={this.state.date}
onChange={this.dateChanged} inline />
</div>
);
}
}
ReactDOM.render(<Application />, document.getElementById('app'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
<script src="https://unpkg.com/react-onclickoutside@5.7.1"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-datepicker/0.37.0/react-datepicker.js"></script>
html, body
height: 100%
body
background: #333
display: flex
justify-content: center
align-items: center
font-family: Helvetica Neue
h1
font-size: 2em
color: #eee
display: inline-block
a
color: white
p
margin-top: 1em
text-align: center
color: #aaa
<link href="https://cdnjs.cloudflare.com/ajax/libs/react-datepicker/0.37.0/react-datepicker.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment