RORK LABJP
GROWTH — Rork keeps growing with 743K monthly visits and an 85% growth rateMAX — Rork Max generates native Swift apps for iPhone, iPad, Watch, TV, Vision Pro, and iMessageMAX — It reaches AR/LiDAR scanning, Metal 3D games, Live Activities, HealthKit, and Core ML, beyond React Native's reachSTACK — Standard Rork builds iOS and Android together in React Native (Expo), so non-engineers can ship real appsPRICE — Plans start free, paid tiers from $25/month, and Rork Max at $200/monthMARKET — Gartner projects 75% of new apps will be low-code or no-code by the end of 2026GROWTH — Rork keeps growing with 743K monthly visits and an 85% growth rateMAX — Rork Max generates native Swift apps for iPhone, iPad, Watch, TV, Vision Pro, and iMessageMAX — It reaches AR/LiDAR scanning, Metal 3D games, Live Activities, HealthKit, and Core ML, beyond React Native's reachSTACK — Standard Rork builds iOS and Android together in React Native (Expo), so non-engineers can ship real appsPRICE — Plans start free, paid tiers from $25/month, and Rork Max at $200/monthMARKET — Gartner projects 75% of new apps will be low-code or no-code by the end of 2026
Articles/Dev Tools
Dev Tools/2026-07-04Intermediate

Should You Show a Read More Link? Let the Rendered Text Decide in Rork (Expo)

Clamping a product description to three lines and adding a Read more toggle sounds simple, until the toggle also appears under single-line text. This walks through measuring the real line count with onTextLayout so the toggle only shows when text actually overflows, covering iOS vs Android quirks, expand animation, and font scaling.

Rork484Expo128React Native193Text UIindie developer36

Premium Article

You add a Read more link under a product description, and then it shows up under a one-line blurb too. Building a wallpaper app on my own, I hit exactly this awkwardness on the detail screen and stopped to fix it properly. Long copy should collapse; short copy needs no toggle at all. The decision to show it or not should come from the number of lines that actually rendered, not from an unreliable proxy like character count. That is what this piece is about.

In React Native, which is the foundation the standard apps Rork generates sit on top of, a Text component will clamp and add an ellipsis when you set numberOfLines. What it will not do is tell you whether clamping happened. To show the toggle correctly, you have to measure whether the rendered body truly exceeds the line limit yourself.

Character counts always break somewhere

The first instinct is a threshold: show the toggle when the body passes 120 characters. It is easy, and it drifts almost immediately. Japanese and English fit wildly different amounts of text per line, and emoji, URLs, and line breaks all move the count. The same 100 characters land in two lines on a wide device and four lines on a small iPhone. Character count guarantees nothing about how many lines appear on screen.

I once shipped the threshold approach. It looked fine in Japanese, then the moment I switched to an English locale a wave of empty toggles appeared under short text. Moving the basis of the decision from input length to the rendered result looked like the long way around, but it was the reliable one.

Read the rendered line count with onTextLayout

React Native's Text has an onTextLayout callback. After the text is laid out, it hands you an array with information about each line. The line count is simply the length of that array.

The crucial detail: do not attach numberOfLines while measuring. If you do, the layout result is rounded to that limit, and you cannot tell whether the text was five lines clamped to three or genuinely three lines. So you measure once with no limit, look at the result, and decide whether the toggle is needed.

import { useState, useCallback } from 'react';
import { Text, Pressable, View, type TextLayoutEventData, type NativeSyntheticEvent } from 'react-native';
 
const COLLAPSED_LINES = 3;
 
type Props = { children: string };
 
export function ExpandableText({ children }: Props) {
  // needsToggle: does the body exceed 3 lines?
  // measured: have we measured once already?
  const [needsToggle, setNeedsToggle] = useState(false);
  const [measured, setMeasured] = useState(false);
  const [expanded, setExpanded] = useState(false);
 
  const onTextLayout = useCallback(
    (e: NativeSyntheticEvent<TextLayoutEventData>) => {
      if (measured) return; // ignore re-layouts after expanding
      const lineCount = e.nativeEvent.lines.length;
      setNeedsToggle(lineCount > COLLAPSED_LINES);
      setMeasured(true);
    },
    [measured],
  );
 
  return (
    <View>
      {/* Measurement pass: render once off-screen with no limit to get the count */}
      {!measured && (
        <Text
          onTextLayout={onTextLayout}
          style={{ position: 'absolute', opacity: 0, left: 0, right: 0 }}
          accessibilityElementsHidden
          importantForAccessibility="no-hide-descendants"
        >
          {children}
        </Text>
      )}
 
      {/* Display pass: clamp with numberOfLines only when collapsed */}
      <Text numberOfLines={expanded ? undefined : COLLAPSED_LINES}>
        {children}
      </Text>
 
      {needsToggle && (
        <Pressable
          onPress={() => setExpanded((v) => !v)}
          hitSlop={8}
          accessibilityRole="button"
          accessibilityLabel={expanded ? 'Collapse text' : 'Read more'}
        >
          <Text style={{ color: '#2563eb', marginTop: 4 }}>
            {expanded ? 'Show less' : 'Read more'}
          </Text>
        </Pressable>
      )}
    </View>
  );
}

The measurement Text is placed off-screen with absolute positioning and zero opacity, rendered once, then removed as soon as the count is known. The display Text applies numberOfLines only while collapsed. This two-layer approach lets you know whether clamping occurred while keeping flicker to a minimum. Always hide the measurement element from screen readers, or the reader will pick up the body twice.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Measure the real rendered line count with onTextLayout and show Read more only when the body exceeds three lines, with working code you can drop in
Avoid the trap where measuring with numberOfLines still attached always rounds down to three lines, and learn why iOS and Android disagree on the count
See why the expand/collapse LayoutAnimation silently does nothing on Android, plus a toggle design that respects VoiceOver and 200% text size
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Dev Tools2026-06-30
Adding Home-Screen Quick Actions to a Rork App — dynamic items without cold-launch drops
How to implement the long-press quick actions on a Rork (Expo) app icon. Covers static vs dynamic items, the iOS/Android differences, and the cold-launch problem where the action arrives before the router is ready — solved with a hold-and-replay design.
Dev Tools2026-06-29
Adding a keyboard toolbar to Rork text inputs — unifying iOS InputAccessoryView and an Android bar into one component
How to add a toolbar pinned above the keyboard — a Done button or quick-insert actions — to the React Native app Rork generates. The iOS InputAccessoryView and a hand-built Android bar, folded into one reusable component, with working code.
Dev Tools2026-06-28
Ship EAS Updates to a Few First, and Halt Automatically on Crash Rate
Because OTA updates reach everyone instantly, a bad update reaches everyone instantly too. Here is a three-layer design: ship EAS Update to a small canary, decide expand-or-halt from crash-free rate automatically, and hold a safety net on the device — with working code.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →