Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

time-picker-react

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-picker-react

time picker for react

latest
Source
npmnpm
Version
0.0.12
Version published
Maintainers
1
Created
Source

React Time Picker

demo

npm install
npm run start:doc:dev

usage

constructor(props) {
    super(props);
    this.state = {
        startTime: moment().valueOf(),
    };
}
componentDidMount() {
    TimePicker.init(this.input, 'startTime', {
      placement: 'bottom-start',
      // time format
      // { year: 2017, month: 10, date: 22, hour: 19, minute: 51, second: 0 }
      // notice month is from 0
      onTimeChange: (time) => {
          this.setState({
              startTime: moment(time).valueOf(),
          });
      },
      time: this.state.startTime,
    });
}
handleShowPicker() {
    TimePicker.show('startTime');
}
render() {
    return (
        <input
          type="text"
          value={moment(this.state.startTime).format('YYYY-MM-DD HH:mm:ss')}
          ref={ele => {this.input = ele;}}
          onFocus={this.handleShowPicker}
        />
    )
}

options

NameDefaultDescription
placement"bottom-start"position
onTimeChangecallback function triggered after time has changed
timenowinitial time
clockPressChangeInterval300mswhen press clock panel chevron, how many time to change once

notice

if run start:doc:dev goes wrong like this:

events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 127.0.0.1:8080

this is because the default port is blocked, only need to edit package.json start:doc:dev, change port field.

Then it will be ok.

Happy coding!

Keywords

javascript

FAQs

Package last updated on 24 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts