Skip to content

MOBILE-5977: Only re-apply iOS view props when they changed - #788

Open
khmMouna wants to merge 1 commit into
mainfrom
MOBILE-5977-ios-view-components-re-apply-props-without-comparing-old-props
Open

khmMouna wants to merge 1 commit into
mainfrom
MOBILE-5977-ios-view-components-re-apply-props-without-comparing-old-props

Conversation

@khmMouna

Copy link
Copy Markdown
Contributor

What do these changes do?

RNAirshipMessageView and RNAirshipEmbeddedView (iOS Fabric components) now compare the new props against oldProps in updateProps and only apply messageId / config when the value actually changed. A missing oldProps is treated as changed so the initial props still apply.

Why are these changes necessary?

Both components applied every prop unconditionally. Any prop change reassigned messageID (whose setter calls loadMessage), reloading the message and losing scroll position, and re-applied the embedded config, re-publishing the embedded ID and selection. Android only invokes setters for changed props, so this brings iOS in line.

How did you verify these changes?

Ran the example app on the iOS simulator with temporary NSLogs in the setMessageID / setConfig setters and a temporary harness (not included) with buttons to change only a style prop or the messageId / embedded ID:

  • Initial mount: both setters fire once.
  • Style-only change (view resized): no reload, no config re-apply.
  • messageId change: message reloads.
  • config change: config re-applied.

The harness used a fake message ID, so scroll position and spinner behavior were not checked against a real message.

Verification Screenshots:

N/A

Anything else a reviewer should know?

sizeToContent in the embedded view is still applied on every update; it was out of scope here.

🤖 Generated with Claude Code

RNAirshipMessageView and RNAirshipEmbeddedView applied every prop on each
updateProps call, so an unrelated prop change reloaded the message or
re-applied the embedded config. Compare against oldProps first.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@khmMouna
khmMouna requested a review from a team as a code owner October 22, 2026 15:34
const auto &newProps = *std::static_pointer_cast<const RNAirshipEmbeddedViewProps>(props);
self.config = [NSString stringWithUTF8String:newProps.config.c_str()];
const auto *old = oldProps ? static_cast<const RNAirshipEmbeddedViewProps *>(oldProps.get()) : nullptr;
if (!old || old->config != newProps.config) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabric passes a null oldProps on Insert, so a cell recycling in a list still re-applies the config and re-publishes the embedded ID — the guard only covers in-place updates. Was in-place update the case you were after, or should re-insertion be covered too?

{
const auto &newProps = *std::static_pointer_cast<const RNAirshipMessageViewProps>(props);
self.messageID = [NSString stringWithUTF8String:newProps.messageId.c_str()];
const auto *old = oldProps ? static_cast<const RNAirshipMessageViewProps *>(oldProps.get()) : nullptr;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: old reads as a bare adjective next to newProps — oldViewProps would pair better.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants