Skip to content

Commit e798772

Browse files
Nick Lefeverfacebook-github-bot
authored andcommitted
Add runtime validation of Props 2.0 output (facebook#54461)
Summary: Compare the output from Props 1.5 with Props 2.0 to detect any missing props in the output coming from Props 2.0. The comparison doesn't run for initial mounts due to Props 1.5 not using the default property values to generate a diff, which is obviously leading to more properties being in the Props 1.5 output that aren't necessary. Changelog: [Internal] Differential Revision: D86577390
1 parent 7486a2b commit e798772

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,25 @@ jni::local_ref<jobject> getProps(
232232
strcmp(
233233
newShadowView.componentName,
234234
newProps->getDiffPropsImplementationTarget()) == 0) {
235-
return ReadableNativeMap::newObjectCxxArgs(
236-
newProps->getDiffProps(oldProps));
235+
auto diff = newProps->getDiffProps(oldProps);
236+
237+
#ifdef REACT_NATIVE_DEBUG
238+
if (oldProps != nullptr) {
239+
auto controlDiff =
240+
diffDynamicProps(oldProps->rawProps, newProps->rawProps);
241+
242+
for (const auto& [prop, value] : controlDiff.items()) {
243+
if (diff.find(prop) == diff.items().end()) {
244+
LOG(ERROR) << "Props diff validation failed: Props 1.5 has prop '"
245+
<< prop.asString() << "' = " << value
246+
<< " that Props 2.0 doesn't have for component "
247+
<< newShadowView.componentName;
248+
}
249+
}
250+
}
251+
#endif
252+
253+
return ReadableNativeMap::newObjectCxxArgs(std::move(diff));
237254
}
238255
if (ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid()) {
239256
if (oldProps == nullptr) {

0 commit comments

Comments
 (0)