react / react/react-native

onTextLayOut is not getting triggered

未关闭
#37,902 11 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Issue: Author Provided Repro
主要语言
C++
星标
127k
派生
25.3k
平均合并
1 天 23 小时
30 天内合并 PR
4

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从链接的 Snack 复现和 Text 组件的 onTextLayout 行为开始;验证在所报告的 React Native 0.70.2 设置中 handler 是否会触发。完成的标准是 handler 会在布局期间触发并提供渲染后的行数,包括文本宽度发生变化时。

由索引模型根据 Issue 内容生成。

评估

技术栈
react-native
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。