Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Adrian Mindak
Adrian Mindak
Courses Plus Student 10,877 Points

Auto shrinking text, to fit in a div, for ReactJS?


I recently rewatched a cool live coding event with Michel Jackson from React-Router (https://www.youtube.com/watch?v=ZtU7Mhf9vN8).

He is building a Calculator and I used a lot of his tips for practice and build a Calculator “myself”. I was hooked by the possibility to have a and the complexity behind the AutoShrinkingTextField. Which is pretty common for a Calculator.

I tried to copy his Code but it does not work and I was trying to find a similar solution.

ReactNative has this Stuff already as a property (https://github.com/facebook/react-native/issues/728 First Comment from the Contributor).

But it seems that React is not so easy in that case.

My question is now: Do anybody know a good jQuery free Solution for AutoShrinkText to fit a div in ReactJS?

I am also interested in Examples or cool Solutions for an auto format for currency or any other units like kilograms, fixing dots and the thousands separators.

I already looked at npm packages(https://www.npmjs.com/search?q=react%20fit%20text&page=1&ranking=optimal). I am looking for a more approved solution or tutorials, to write and understand a class in combination with refs, like Micheal did in the live coding event, by myself.

Thx so much, this is my second time I ever ask something in forums :P. I am pretty excited !!! Best Adrian