Multiline controlled input enters an infinite loop on iOS
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C++
- Sterne
- 127k
- Forks
- 25.3k
- Ø Merge
- 1 T. 23 Std.
- Gemergte PRs (30 T.)
- 4
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem verlinkten rn-bug-loop-Reproducer und reproduziere die Endlosschleife auf iOS mit dem im Issue gezeigten kontrollierten mehrzeiligen TextInput. Vergleiche das Verhalten, wenn multiline entfernt wird, und verfolge anschließend den beteiligten React Native TextInput-Pfad; abgeschlossen ist die Aufgabe, wenn eine kontrollierte mehrzeilige Eingabe nicht mehr in einer Schleife läuft und das gemeldete Setup weiterhin funktioniert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ios, javascript, react-native
- Bereich
- mobile-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100