GithubHelp home page GithubHelp logo

radekmie / react-timepicker Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 12.0 61 KB

React timepicker in Android KitKat style

CSS 22.24% JavaScript 77.76%
timepicker react android-kitkat react-component component react-library

react-timepicker's People

Contributors

radekmie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-timepicker's Issues

Wrong import in 'Quick Start' example

Hi, nice work on this TimePicker.

You're importing Timepicker as default in your example but there's no default export in your component file.

I suggest to export Timepicker as default or correct the import in the example.
Btw you can also show the css import to demonstrate a full working example :

import { Timepicker } from 'react-timepicker';
import 'react-timepicker/timepicker.css';

Error: Cannot set property 0 of undefined

Steps to reproduce:
Chrome

  1. Set militaryTime = False
  2. Open the time picker (should open in 12 hr mode)
  3. Click on 12.

-->Throws an error: "Cannot set property 0 of undefined " in the console

In the provided example html, this will recreate the bug

 ReactDOM.render(React.createElement(Timepicker, {
                    militaryTime: false,
                    hours:   new Date().getHours(),
                    minutes: new Date().getMinutes()
                }), root);

Support for React 16.0?

Two warning:

Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs
console.warn node_modules/react/lib/lowPriorityWarning.js:40

Warning: Accessing createClass via the main React package is deprecated, and will be removed in React v16.0. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class v15.* is available on npm as a temporary, drop-in replacement. For more info see https://fb.me/react-create-class

Any plans to catch up with this?

React 16 issue

hey! cool stuff :)
i've upgraded React to v16 and it doesn't seem to work with it.

here's the relevant stack trace:

timepicker.js:1 Uncaught ReferenceError: positions is not defined
    at b.calculatePositionsHours (timepicker.js:1)
    at new b (timepicker.js:1)

if you'd add the source files to the repo (not just the minified) i'd be happy to take a look.

componentWillReceiveProps don't receive updated values

I wrapped the Timepicker in the following class:

import React, { Component } from 'react';
import Timepicker from 'react-timepicker';
import 'react-timepicker/timepicker.css';

class AwesomeTimePicker extends Component {
    constructor(props) {
        super(props);

        var time = this.props.defaultValue ? this.props.defaultValue.split(':') : [0, 0];

        this.state = {
            hours: parseInt(time[0]),
            minutes: parseInt(time[1])
        }
    }

    componentWillReceiveProps(nextProps) {
        var time = nextProps.defaultValue ? nextProps.defaultValue.split(':') : [0, 0];
        this.setState({
            hours: parseInt(time[0]),
            minutes: parseInt(time[1])
        });
    }

    onChangeTimePicker(hours, minutes) {
        if (hours && (hours === undefined || hours === null)) {
            hours = 0;
        }

        if (minutes && (minutes === undefined || minutes === null)) {
            hours = 0;
        }

        this.props.handleValue(this.props.name, hours + ":" + minutes);
    }

    render() {
        console.log(this.state.hours, this.state.minutes);
        const newProps = {
            hours: this.state.hours,
            minutes: this.state.minutes,
            onChange: this.onChangeTimePicker.bind(this),
            radius: 110
        }
        return (
            <Timepicker radius={110} hours={this.state.hours} minutes={this.state.minutes} onChange={this.onChangeTimePicker.bind(this)} />
        );
    }
}

export default AwesomeTimePicker;

But when the hours or minutes properties change the timepicker does not update the values.

I've been debuging and I found that the componentWillReceiveProps method don't receive the updated values when my render method call it.

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.