arqex / react-datetime

A lightweight but complete datetime picker react component.
2k stars 870 forks source link

NOT a bug!! Just a request for a tiny edit in documentation for renderInput #819

Open ShariqKhan2012 opened 2 years ago

ShariqKhan2012 commented 2 years ago

I'm Submitting a ...

[x ] Bug report
[ ] Feature request
[ ] Support request

Steps to Reproduce

Expected Results

Actual Results

Minimal Reproduction of the Problem

Other Information (e.g. stacktraces, related issues, suggestions how to fix)

Again, just want to stress that this is not actually a bug, just an omission in the documentation that needs to be added. I wasn't sure how to request edits in the documentation, so created an issue.

The renderInput example has this code:

class MyDTPicker extends React.Component {
    render(){
        return <Datetime renderInput={ this.renderInput } />;
    }
    renderInput( props, openCalendar, closeCalendar ){
        function clear(){
            props.onChange({target: {value: ''}});
        }
        return (
            <div>
                <input {...props} />
                <button onClick={openCalendar}>open calendar</button>
                <button onClick={closeCalendar}>close calendar</button>
                <button onClick={clear}>clear</button>
            </div>
        );
    }
}

In this (or similar) examples, one should change the line:

return <Datetime renderInput={ this.renderInput } />;

to

return <Datetime renderInput={ this.renderInput } {...this.props}/>;

For functional components, it should be:

return <Datetime renderInput={ this.renderInput } {...props}/>;

Thanks for the great component. I am using it in my project and like the simplicity with the flexibility it offers.