Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


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