Comments (12)
You should use value
to control the component.
https://facebook.github.io/react/docs/forms.html#controlled-components
from time-picker.
That also doesn't work
class CustomTimePickerModal extends React.Component {
constructor(props){
super(props);
this.state = { value: this.props.defaultValue };
}
onChange = value => {
this.setState({ value: value });
this.props.onChange(value)
}
render() {
return (
<div className={styles.timepicker}>
<TimePicker showSecond={false} onChange={this.onChange} clearText={'Close the Picker'} value={this.state.value} placeholder={`${moment().format('hh:mm')}` || `${moment().format('hh:mm')}`} />
</div>
);
}
}
from time-picker.
The value should be a moment instance but moment().format('xx')
is not one.
from time-picker.
That's how I am passing the value to the custom component defaultValue={moment(task.realizedStartTime)}
from time-picker.
That's the moment object which is created
from time-picker.
That formated value was passed to placeholder prop not to value
placeholder={
${moment().format('hh:mm')}||
${moment().format('hh:mm')}}
from time-picker.
Could you provide a reproducible demo by forking this: https://codesandbox.io/s/mrq288569 ?
from time-picker.
Here is it https://codesandbox.io/s/zqww68629p
As you can check it doesn't return the correct value in the console.
from time-picker.
I think the issue was probably related to call back as I am getting the correct value in the component call back who is using the date picker.
from time-picker.
@Mujaddadi I am facing same problem. did you fix this one?
from time-picker.
@Rainpia I started using some other date picker. As you can see this issue is almost 2 years old and still open, I don't have hope that the developer has time to fix it.
from time-picker.
For me using moment(offStartTime, 'HH:mm')
instead of moment(offStartTime).format('HH:mm')
did the trick
from time-picker.
Related Issues (20)
- TypeScript error when using autoComplete
- Add event as param in onChange.
- Save the 3.x branch for support antd 3.x hot patching and bug fixes
- Any way to put '00' instead of '12' when using use12Hours format and is selected 'am'? HOT 1
- Custom input component
- Allow manual input to "go to"
- Moderately Severe NPM Warnings
- localize HOT 1
- Not able to set initial state with custom time: "18:10" HOT 1
- getPopupContainer missing in the TimePickerProps [TypeScript] HOT 2
- inputClassName does not work HOT 1
- Any Way to Start from 01 in 12 hours format
- Change focus on arrow up/down and change column on Tab
- Allow to type any hours/minutes/seconds when hoursStep/minuteStep/secondStep is defined
- Disabling 12 (time) hour will disable "1" & "2" also
- is it still safe to use in 2021 as of May , it shows a lot of warnings. HOT 2
- rc time picker select dropdown is rendering outside the root element not at the position where i have called timepicker within project HOT 5
- not compatible with StrictMode HOT 3
- getPopupContainer missing in the TimePickerProps [TypeScript]
- Timepicker popup stays fixed if used in Modal HOT 2
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 time-picker.