You have a nice network of refs set up within each composite, but no way to access the composite itself from outside the tree.
For example, if I wanted to focus the input I can't. It would be nice to be able to do this:
React.findDOMNode(this.refs.datepicker.refs.dateinput.refs.input).focus()
A little ugly, definitely. But if you decide to change classes or the type of element being rendered later my code won't break.
Second this.
I would love this feature as well.
I just figured out a way to focus the input box.
Give the DatePicker a ref, like so:
< DatePicker ref="datePicker"/ >
Then somewhere call:
this.refs.datePicker.handleFocus();
Does that resolve your issues? Otherwise, I'll be happy to merge a PR if someone could add some refs.
It does for me.
@Thomsos your solution definitely works, but doesn't address the issue that we shouldn't be touching the internals of @martijnrusschen's components.
Still think it would be a good idea to add some refs. Will send a PR later on
I am using the datepicker in a functional component where I use it along with redux-form and redux-form doesn't allow me to define ref in a functional component. All I could do is update the source code of this with my bare hands to avoid the error. Can this be made optional instead?
Most helpful comment
I just figured out a way to focus the input box.
Give the DatePicker a ref, like so:
< DatePicker ref="datePicker"/ >
Then somewhere call:
this.refs.datePicker.handleFocus();