fix: re-run transformer on transformerId prop change#5
Merged
janicduplessis merged 1 commit intomainfrom Apr 25, 2026
Merged
Conversation
The native decorator view only registered the new transformer when the
prop changed; the existing displayed text was not re-transformed until
the next keystroke. This forced consumers to call update({transform:true})
themselves whenever they swapped transformer instances (e.g., a currency
picker switching between USD/EUR/JPY).
iOS and Android now detect a transformerId change after mount and
re-run the new transformer on the current value, applying any new
formatting and selection. The initial prop set is excluded so the
JS-side defaultValue pre-transform still owns the first render.
The example app's currency picker drops its useEffect workaround.
2230f97 to
e4302f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a consumer swaps the
transformerprop onTransformerTextInput(e.g., a currency picker switching between USD/EUR/JPY instances), the native decorator only registered the new transformer in the registry — it did not re-run it on the existing displayed text. The user would see the old formatting until they typed a keystroke, at which point the new transformer would finally run. The example app worked around this with auseEffect([currency])that calledinputRef.current.update({ transform: true })after every picker change.Solution
iOS and Android both detect the
transformerIdchange at the same place they already update the registry lookup, and additionally re-run the new transformer on the current text + selection when the change happens after mount. If the resulting value or selection differs, they apply it (and on iOS, notify the base text-input delegate so React'sonChangeTextfires once).The initial prop set is excluded by checking that the previous transformerId was non-zero (the default before the first React-driven set) and that the backing text-input view is attached. The JS-side
transformedDefaultValuecontinues to own the very first render.The example app drops its
useEffectworkaround — switching the currency picker reformats the displayed amount on its own now.Test plan
1234567→\$12,345.67).12.345,67 €.¥1,234,567(no decimals, all whole units).\$12,345.67again.