Skip to content

Commit

Permalink
Fix TextInput value not restoring after reuse
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

# Problem

The problem was setting `_backedTextInputView.attributedText` to nil inside `[RCTTextInputComponentView prepareForRecycle]`.

Ordinarily this isn't a problem becase `UIManager::updateState` drops the update if the ShadowNode no longer exists. But in certain cases the ShadowNode can exist, empty string being set as its value

# Fix

Fix is trivial, invalidate state before nullifying `_backedTextInputView`. This prevents the state update from being dispatched.

# Discussion

We should go over all other components and make sure state is invalidated as first thing in `[RCTViewComponentView prepareForRecycle]`.

Reviewed By: shergin

Differential Revision: D23324929

fbshipit-source-id: 9568e920d99683ad95f965ef4b63c529f50f3283
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Aug 25, 2020
1 parent 19cd630 commit 9b973f3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ - (void)updateLayoutMetrics:(LayoutMetrics const &)layoutMetrics
- (void)prepareForRecycle
{
[super prepareForRecycle];
_stateTeller.invalidate();
_backedTextInputView.attributedText = nil;
_mostRecentEventCount = 0;
_stateTeller.invalidate();
_comingFromJS = NO;
_lastStringStateWasUpdatedWith = nil;
_ignoreNextTextInputCall = NO;
Expand Down

0 comments on commit 9b973f3

Please sign in to comment.