Code Monkey home page Code Monkey logo

Comments (12)

afc163 avatar afc163 commented on August 30, 2024

You should use value to control the component.

https://facebook.github.io/react/docs/forms.html#controlled-components

from time-picker.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

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.

afc163 avatar afc163 commented on August 30, 2024

The value should be a moment instance but moment().format('xx') is not one.

from time-picker.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

That's how I am passing the value to the custom component defaultValue={moment(task.realizedStartTime)}

from time-picker.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

That's the moment object which is created

s

from time-picker.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

That formated value was passed to placeholder prop not to value
placeholder={${moment().format('hh:mm')}||${moment().format('hh:mm')}}

from time-picker.

afc163 avatar afc163 commented on August 30, 2024

Could you provide a reproducible demo by forking this: https://codesandbox.io/s/mrq288569 ?

from time-picker.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

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.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

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.

Rainpia avatar Rainpia commented on August 30, 2024

@Mujaddadi I am facing same problem. did you fix this one?

from time-picker.

Mujaddadi avatar Mujaddadi commented on August 30, 2024

@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.

mirceaciu avatar mirceaciu commented on August 30, 2024

For me using moment(offStartTime, 'HH:mm') instead of moment(offStartTime).format('HH:mm') did the trick

from time-picker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.