DEV Community

Discussion on: Fixing Dev.to's scrollbar bug with a single line of code

Collapse
 
eaich profile image
Eddie

Great job on the bug hunt. Now the real question is, why is a 3rd party package required in order to implement an auto-sizing textarea?

Collapse
 
almenon profile image
Almenon • Edited

My rule of thumb is if the package fits your use case, is more than a couple lines, and has been updated sometime recently, it's probably best to re-use it instead of writing your own code. If you try re-writing the code on your own you will probably discover the situation is more complex than it appears and end up spending more time than you allocated. In this case react-textarea-autosize is two files of code, so I can understand why they used a package.

On the other hand it hasn't been kept up to date, last commit in 2016 and it's 166 commits behind the original repo. I'm not a preact developer so I'm not sure how hard it would be to adapt the original repo for preact. I'm guesing I would just stick with the old preact version. ¯\(ツ)