@@ -15,6 +15,29 @@ const getNativeComponentAttributes = require('getNativeComponentAttributes');
1515
1616import type { ReactNativeBaseComponentViewConfig } from 'ReactNativeTypes' ;
1717
18+ /**
19+ * The purpose of this function is to validate that the view config that
20+ * native exposes for a given view manager is the same as the view config
21+ * that is specified for that view manager in JS.
22+ *
23+ * In order to improve perf, we want to avoid calling into native to get
24+ * the view config when each view manager is used. To do this, we are moving
25+ * the configs to JS. In the future we will use these JS based view configs
26+ * to codegen the view manager on native to ensure they stay in sync without
27+ * this runtime check.
28+ *
29+ * If this function fails, that likely means a change was made to the native
30+ * view manager without updating the JS config as well. Ideally you can make
31+ * that direct change to the JS config. If you don't know what the differences
32+ * are, the best approach I've found is to create a view that prints
33+ * the return value of getNativeComponentAttributes, and then copying that
34+ * text and pasting it back into JS:
35+ * <Text selectable={true}>{JSON.stringify(getNativeComponentAttributes('RCTView'))}</Text>
36+ *
37+ * This is meant to be a stopgap until the time comes when we only have a
38+ * single source of truth. I wonder if this message will still be here two
39+ * years from now...
40+ */
1841function verifyComponentAttributeEquivalence (
1942 componentName : string ,
2043 config : ReactNativeBaseComponentViewConfig < > ,
0 commit comments