react / react/react-native

onTextLayOut is not getting triggered

Open
#37,902 11 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Author Provided Repro
Dominant language
C++
Stars
127k
Forks
25.3k
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Description

For a text component , if we specify onTextLayout and write log statement, its not getting triggered.

i wanted to use the onTextLayout to get the no of lines being rendered for a given text width. The no of lines might change based on the width prop in style.

Therefor, i would like to get the no of lines to do some operation on text when it exceeds max lines limit.

React Native Version

0.70.2

Output of npx react-native info

N/A

Steps to reproduce

Write a text component and define "onTextLayout" prop to send in the handler.

The handler doesn't get triggered even during the first layout render.

Snack, code example, screenshot, or link to a repository

https://snack.expo.dev/Wff9zMnHx

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Snack reproduction and the Text component's onTextLayout behavior; verify whether the handler fires on the reported React Native 0.70.2 setup. Done means the handler fires during layout and exposes the rendered line count, including when the text width changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.