-
Notifications
You must be signed in to change notification settings - Fork 83
How to get textarea value with ref? (Performance optimization) #63
Comments
Hi @philipyoungg, what do you mean by
How slow? Do you see a perceptible lag during the input? Also
What have you tried, what doesn't work? Can you show a self-contained example that we can use to reproduce the behavior you're seeing? |
Hello @gabro, that's for the speedy follow up! Yes, I experienced perceptible lag during input. I have tried using Case: I'm making a to do app with multiple list. [lists of item]
[controlled textarea input] On a page with only several todo list, there's no lag whatsoever. That's why I'm going to uncontrolled route to improve performance. |
Hi @philipyoungg and sorry for the delay, I'm pretty sure your performance issues are caused by useless re-renders that could be avoided, which would explain why you notice that only with a lot of items. I'll explain myself better: whenever you type I assume you are causing somehow each item of the list to re-render, which is very expensive. I suggest you to use let's suppose you have an item with two props: shouldComponentUpdate(nextProps) {
return nextProps.value !== this.props.value;
} You can read more about this here: https://facebook.github.io/react/docs/optimizing-performance.html#shouldcomponentupdate-in-action Let me know if this helps you :)
EDIT: see comment in #64 for a simple implementation that wraps the component with a |
I'm closing this for now, if anyone still has perf problems feel free to comment here :) |
I want to switch to
uncontrolled component
to optimize performance. Currently adding input with controlled component is super slow.I've tried using
ref
andinnerRef
to getthis.textarea.value
. It doesn't work.The text was updated successfully, but these errors were encountered: