-
Notifications
You must be signed in to change notification settings - Fork 61
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
inputRef keeps triggering #88
Comments
Thanks heaps for an example. I’ll have a look when I’m back from holidays
…--
Nik Butenko
[email protected]
http://github.com/nkbt
|
@Pomax Did you end up with a solution here? |
not one I would advocate, we just put some nonsense in place while we waited for @nkbt to have a better look than we could. |
It does not make too much sense to me either since there is no underlying element re-creation in place so react should mount and unmount it again (but it does!). Will have to remove props one by one to see which is causing unnecessary unmount =( |
Those are the bad cases to debug =( Many thanks for having a look, though! |
Does DebounceInput involve function components? That might be the problem. I was trying to assign focus a DebounceInput element created dynamically after hitting Enter. If I change it to a normal input element it works. React documentation says:
https://reactjs.org/docs/refs-and-the-dom.html EDIT: I found the solution: use inputRef instead of ref #112 (comment) But for me I was rendering an element other than 'input', so it still doesn't work but I it's probably outside the scope of DebounceInput to pass a ref to another component. In my case TextAreaAutosize https://github.com/andreypopp/react-textarea-autosize |
The
inputRef
function seems to get triggered an inordinate number of times - I had expected it to fire once during the DebounceInput'scomponentDidMount
lifecycle function, but instead it also fires (twice) for every key input sent into the DebounceInput component.Updating https://codepen.io/nkbt/pen/VvmzLQ?editors=0010 to have an extra line of code at L89 that looks like
inputRef={ ref => console.log('ref triggered. Actual data?', !!ref) }
, and looking at the console, you should see more console output than should reasonably be the case while typing in the textfield =)Also it seems to trigger twice, where the first call doesn't actually have a ref to work with, while the second call does. Not sure why, but that also seems a bit odd.
The text was updated successfully, but these errors were encountered: