Show HN: React hooks that predict text height before render, using font metrics

8 pointsposted 20 hours ago
by ahmadparizaad

Item id: 47639940

2 Comments

pverheggen

14 hours ago

FYI, useLayoutEffect gets you what you're looking for. Since it fires before repaint, you can take measurements and modify the DOM without the user seeing any layout shift.

It's a creative solution though! I always like seeing out of the box thinking on front end problems.

kraftaa

15 hours ago

Neat. Have you seen differences across browsers? Feels like the hard part here is more about matching browser quirks over time than about math.