how to target the same element im styling in react?

I have a textarea element in React and I want to style it’s height based on it’s content.

I need to get an ‘event’ property to get the target and send it to a resize function I have,
it’s possible to do on an ‘onchange’ listener, but I’m trying to do this in ‘style’.

this is working:

onChange={e => resizeTextarea(e)}

but I’m struggling with this:

style={{height: this.scrollHeight}}

I have way more adjustments to do with the height(the logic is in the ‘resizeTextarea’ function),
but I have tried using scrollHeight just to see how to get the target element, and well, using ‘this’ or ‘self’ doesn’t work, how can I achieve what I’m trying to do?

1 thought on “how to target the same element im styling in react?”

Leave a Comment