react-simple-timefield
Simple React time input field, check out demo.


Installation
npm install --save react-simple-timefield
Usage
import TimeField from 'react-simple-timefield';
...
<TimeField
value={time}
onChange={(event, value) => {...}}
input={<MyCustomInputElement />}
inputRef={(ref) => {...}}
colon=":"
showSeconds
/>
Real world example
import TimeField from 'react-simple-timefield';
class App extends React.Component {
constructor(...args) {
super(...args);
this.state = {
time: '12:34'
};
this.onTimeChange = this.onTimeChange.bind(this);
}
onTimeChange(event, time) {
this.setState({time});
}
render() {
const {time} = this.state;
return (
<TimeField value={time} onChange={this.onTimeChange} />
);
}
}
Migrate version 2.x to version 3.x
There is a breaking change in version 3.
The onChange
callback property will be called with two arguments.
<TimeField onChange={(value) => console.log(value)} />
<TimeField onChange={(event, value) => console.log(event, value)} />
Contributing
Run demo:
For running demo locally, replace:
import TimeField from '../';
import TimeField from '../src';
in demo/index.tsx
file.
cd demo
npm install
npm install --only=dev
npm run dev
Build:
npm install
npm install --only=dev
npm test
npm run format
npm run build
License
MIT License. Free use and change.