Skip to content

Commit 7cdaca7

Browse files
mdvaccafacebook-github-bot
authored andcommitted
[skip ci] Implement prop diffing for basic props in <View> (facebook#48829)
Summary: This diff implements the diffing for basic props of <View> changelog: [internal] internal Reviewed By: NickGerleman Differential Revision: D59972040
1 parent 02ba29f commit 7cdaca7

File tree

1 file changed

+106
-0
lines changed
  • packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view

1 file changed

+106
-0
lines changed

packages/react-native/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,116 @@ folly::dynamic HostPlatformViewProps::getDiffProps(
145145
? &defaultProps
146146
: static_cast<const HostPlatformViewProps*>(prevProps);
147147

148+
if (this == oldProps) {
149+
return result;
150+
}
148151
if (focusable != oldProps->focusable) {
149152
result["focusable"] = focusable;
150153
}
151154

155+
if (hasTVPreferredFocus != oldProps->hasTVPreferredFocus) {
156+
result["hasTVPreferredFocus"] = hasTVPreferredFocus;
157+
}
158+
159+
if (needsOffscreenAlphaCompositing !=
160+
oldProps->needsOffscreenAlphaCompositing) {
161+
result["needsOffscreenAlphaCompositing"] = needsOffscreenAlphaCompositing;
162+
}
163+
164+
if (renderToHardwareTextureAndroid !=
165+
oldProps->renderToHardwareTextureAndroid) {
166+
result["renderToHardwareTextureAndroid"] = renderToHardwareTextureAndroid;
167+
}
168+
169+
if (opacity != oldProps->opacity) {
170+
result["opacity"] = opacity;
171+
}
172+
173+
if (backgroundColor != oldProps->backgroundColor) {
174+
result["backgroundColor"] = *backgroundColor;
175+
}
176+
177+
if (shadowColor != oldProps->shadowColor) {
178+
result["shadowColor"] = *shadowColor;
179+
}
180+
181+
if (shadowOpacity != oldProps->shadowOpacity) {
182+
result["shadowOpacity"] = shadowOpacity;
183+
}
184+
185+
if (shadowRadius != oldProps->shadowRadius) {
186+
result["shadowRadius"] = shadowRadius;
187+
}
188+
189+
if (shouldRasterize != oldProps->shouldRasterize) {
190+
result["shouldRasterize"] = shouldRasterize;
191+
}
192+
193+
if (collapsable != oldProps->collapsable) {
194+
result["collapsable"] = collapsable;
195+
}
196+
197+
if (removeClippedSubviews != oldProps->removeClippedSubviews) {
198+
result["removeClippedSubviews"] = removeClippedSubviews;
199+
}
200+
201+
if (onLayout != oldProps->onLayout) {
202+
result["onLayout"] = onLayout;
203+
}
204+
205+
if (zIndex != oldProps->zIndex) {
206+
result["zIndex"] = zIndex.value();
207+
}
208+
209+
if (pointerEvents != oldProps->pointerEvents) {
210+
std::string value;
211+
switch (pointerEvents) {
212+
case PointerEventsMode::BoxOnly:
213+
result["pointerEvents"] = "box-only";
214+
break;
215+
case PointerEventsMode::BoxNone:
216+
result["pointerEvents"] = "box-none";
217+
break;
218+
case PointerEventsMode::None:
219+
result["pointerEvents"] = "none";
220+
break;
221+
default:
222+
result["pointerEvents"] = "auto";
223+
break;
224+
}
225+
226+
if (nativeId != oldProps->nativeId) {
227+
result["nativeId"] = nativeId;
228+
}
229+
230+
if (testId != oldProps->testId) {
231+
result["testId"] = testId;
232+
}
233+
234+
if (accessible != oldProps->accessible) {
235+
result["accessible"] = accessible;
236+
}
237+
238+
if (getClipsContentToBounds() != oldProps->getClipsContentToBounds()) {
239+
result["overflow"] = getClipsContentToBounds() ? "hidden" : "visible";
240+
result["scroll"] = result["overflow"];
241+
}
242+
243+
if (backfaceVisibility != oldProps->backfaceVisibility) {
244+
switch (backfaceVisibility) {
245+
case BackfaceVisibility::Auto:
246+
result["backfaceVisibility"] = "auto";
247+
break;
248+
case BackfaceVisibility::Visible:
249+
result["backfaceVisibility"] = "visible";
250+
break;
251+
case BackfaceVisibility::Hidden:
252+
result["backfaceVisibility"] = "hidden";
253+
break;
254+
}
255+
}
256+
}
257+
152258
return result;
153259
}
154260

0 commit comments

Comments
 (0)