Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with latest version of react? #99

Closed
goranefbl opened this issue Sep 12, 2018 · 1 comment
Closed

Does not work with latest version of react? #99

goranefbl opened this issue Sep 12, 2018 · 1 comment

Comments

@goranefbl
Copy link

goranefbl commented Sep 12, 2018

The simplest example is not updating time:

import React, { Component } from 'react';
import TimePicker from 'react-times';

import 'react-times/css/material/default.css';

export default class DatePicker extends Component {
    constructor(props) {
        super(props);
        this.state = {
            time: '01:45'
        };
        console.log(this.state);
    }

    handleTimeChange = time => {
        const { hour, minute } = time;
        console.log(hour, minute);
       this.setState(() => ({ time: `${hour}:${minute}` }));
        console.log(this.state);
    };

    render() {
        const { label, name, parentClass } = this.props;
        let { required } = this.props;
        const { time } = this.state;
        console.log(time);
        if (required) {
            required = <span className="form__required">* (required)</span>;
        }

        return (
            <div className={parentClass}>
                <label htmlFor={name}>
                    {label}
                    {required}
                </label>

                <TimePicker time={time} onTimeChange={e => this.handleTimeChange(e)} />
            </div>
        );
    }
}

Looking at the console, when I change hours, I do see that state get hours changed, but when I change a minutes, I see that state got the old hours. Component is not rerendering.

@goranefbl
Copy link
Author

It was issue on my side...Closing comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant