react-currency-input
react-currency-input copied to clipboard
how to trigger focus() on <CurrencyInput />
I would like to trigger the focus() event on the <CurrencyInput /> when a button is pressed. However, I'm not sure how to do so.
When I use ref={el => this.input = el}, I don't get access to the component.
Can we expose a way to add a ref to the component so that we can call focus() and other triggers? Thank you.
Any update to this? @tgoldenberg did you ever find a solution?
@cavaloni you can access the actual element like this:
ref={el => this.currencyInput = el} and then later reference the actual input via theInput property. e.g. this.currencyInput.theInput.focus(). I wasn't able to reference theInput in the actual ref callback because sometimes el was null. Perhaps you could do a truthy check but I didn't test that myself