react / react/react-native

Multiline controlled input enters an infinite loop on iOS

オープン
#46,850 コメント 11 件 リアクション 27 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Issue: Author Provided Repro Platform: iOS
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

This code enters an infinite loop on iOS.

import React, {useState, memo} from 'react'
import {TextInput} from 'react-native'

let App = () => {
  console.log('render App')
  const [outlet, setOutlet] = useState(null)
  return (
    <>
      <Outlet outlet={outlet} />
      <Child setOutlet={setOutlet} />
    </>
  )
}
export default App

let Child = memo(({setOutlet}) => {
  console.log('render Child')
  const [value, setValue] = useState('')
  return (
    <Portal setOutlet={setOutlet}>
      <TextInput
        onChangeText={text => setValue(text)}
        value={value}
        multiline
        style={{
          backgroundColor: 'red',
          marginTop: 200,
        }}
      />
    </Portal>
  )
})

let Outlet = memo(({outlet}) => {
  console.log('render Outlet')
  return outlet
})

let Portal = memo(({children, setOutlet}) => {
  console.log('render Portal')
  React.useLayoutEffect(() => {
    setOutlet(children)
  }, [children])
  return null
})

Removing multiline prop fixes the issue.

I suspect this may be related to https://github.com/facebook/react-native/issues/36494 but who knows.

Steps to reproduce

See above

React Native Version

0.75.4

Affected Platforms

Runtime - iOS

Output of npx react-native info
System:
  OS: macOS 14.6.1
  CPU: (16) arm64 Apple M3 Max
  Memory: 53.04 GB / 128.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 22.8.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.09.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
Stacktrace or Logs
n/a
Reproducer

https://github.com/gaearon/rn-bug-loop

Screenshots and Videos

https://github.com/user-attachments/assets/9ddf62e5-4322-4d8e-bfd7-c34d94ec773b

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされている rn-bug-loop の再現コードから始め、issue に示されている制御された multiline TextInput を使って iOS で無限ループを再現します。multiline を削除した場合の動作と比較し、その後、関係する React Native TextInput の経路を追跡します。制御された multiline 入力がループしなくなり、報告されているセットアップが引き続き機能すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
ios, javascript, react-native
領域
mobile-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。