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 this datepicker support React? #107

Open
javeedrahman opened this issue Mar 16, 2019 · 2 comments
Open

Does this datepicker support React? #107

javeedrahman opened this issue Mar 16, 2019 · 2 comments

Comments

@javeedrahman
Copy link

No description provided.

@kevinfiol
Copy link

Hey @javeedrahman . I'm a little late, but you can easily integrate this lib (and other vanilla JS libs) in React by using a ref. Take a look https://reactjs.org/docs/integrating-with-other-libraries.html

@johannes-ross
Copy link

Hey, just ran over the same "Problem". I made a wrapper class:

import React from "react";
import TinyDatePicker from 'tiny-date-picker';
// Make sure, we have all the CSS
import 'tiny-date-picker/tiny-date-picker.min.css';

export default class TinyDatePickerReact extends React.Component {
        // I use TypeScript so el is any
	el:any = null;
	componentDidMount() {
                // create the Datepicker
		this.el = TinyDatePicker(this.el);
                // Do something with it
		this.el.open();
	}

	componentWillUnmount() {
                // If this compontents gets removed, remove the Datepicker first
		this.el.destroy();
	}

	render() {
                // reference an input element
		return <input ref={el => this.el = el} />;
	}
}

Hope I could help.

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

3 participants