react-input-mask icon indicating copy to clipboard operation
react-input-mask copied to clipboard

findDOMNode is deprecated; need to use a ref

Open joefiorini opened this issue 6 years ago • 3 comments

Going to try to open a PR for this, but wanted to bring it up in an issue first. findDOMNode is deprecated in favor of refs. I think the safest way to fix this would be to create a single ref that is used in one of two ways:

  1. When using a render prop, pass the ref into the render prop function and require the developer to pass it down to their input (I believe there is precedence for this in other libraries, but need to verify that...)
  2. When not using a render prop, pass the ref straight to the default input that is controlled directly by the input mask component.

I'm going to try this and see what it does to the tests. If it works out, I'll open a PR for it, unless I hear objections here.

joefiorini avatar Jan 07 '19 21:01 joefiorini

Need this feature to. Im using react-input-mask with react-datepicker and datepicker passes own onFocus handler to input. But my custom input wrapped inside with <div>, so I need input ref to handle focus properly. If I get ref as suggested in closed issues: ref={ref => this.input = findDOMNode(ref)} I get next eslint warns: image So it don`t feels like clean solution

De-Santa avatar Jan 21 '19 09:01 De-Santa

<React.StrictMode> <InputMask mask="99/99/9999" onChange={props.onChange} value={props.value} /> </React.StrictMode>

skaziweb avatar Mar 27 '20 18:03 skaziweb

I have the same problem. I send PR to fix this issue.

https://github.com/sanniassin/react-input-mask/pull/255

Temirtator avatar Apr 06 '21 10:04 Temirtator