Skip to content

Commit a93b8db

Browse files
committed
feat(ReactNative): prioritize attribute config process function to allow processing function props (#32119)
## Summary In react-native props that are passed as function get converted to a boolean (`true`). This is the default pattern for event handlers in react-native. However, there are reasons for why you might want to opt-out of this behavior, and instead, pass along the actual function as the prop. Right now, there is no way to do this, and props that are functions always get set to `true`. The `ViewConfig` attributes already have the API for a `process` function. I simply moved the check for the process function up, so if a ViewConfig's prop attribute configured a process function this is always called first. This provides an API to opt out of the default behavior. This is the accompanied PR for react-native: - facebook/react-native#48777 ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> I modified the code manually in a template react-native app and confirmed its working. This is a code path you only need in very special cases, thus it's a bit hard to provide a test for this. I recorded a video where you can see that the changes are active and the prop is being passed as native value. For this I created a custom native component with a view config that looked like this: ```js const viewConfig = { uiViewClassName: 'CustomView', bubblingEventTypes: {}, directEventTypes: {}, validAttributes: { nativeProp: { process: (nativeProp) => { // Identity function that simply returns the prop function callback // to opt out of this prop being set to `true` as its a function return nativeProp }, }, }, } ``` https://github.com/user-attachments/assets/493534b2-a508-4142-a760-0b1b24419e19 Additionally I made sure that this doesn't conflict with any existing view configs in react native. In general, this shouldn't be a breaking change, as for existing view configs it didn't made a difference if you simply set `myProp: true` or `myProp: { process: () => {...} }` because as soon as it was detected that the prop is a function the config wouldn't be used (which is what this PR fixes). Probably everyone, including the react-native core components use `myProp: true` for callback props, so this change should be fine. DiffTrain build for [911dbd9](911dbd9)
1 parent fa02f0e commit a93b8db

24 files changed

+112
-112
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.2.0-native-fb-d742611c-20250603
1+
19.2.0-native-fb-911dbd9e-20250609

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5ba333cdabfedacaf43ebe3d5bc6b1a1>>
10+
* @generated SignedSource<<c14400fab716dfc2cc998e82f9795693>>
1111
*/
1212

1313
"use strict";
@@ -404,5 +404,5 @@ __DEV__ &&
404404
exports.useFormStatus = function () {
405405
return resolveDispatcher().useHostTransitionStatus();
406406
};
407-
exports.version = "19.2.0-native-fb-d742611c-20250603";
407+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";
408408
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<4c9ba4316d4a235a6fff958e9a060379>>
10+
* @generated SignedSource<<e63a489a1e565aeee1f75d2c73cea4a1>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-d742611c-20250603";
206+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<4c9ba4316d4a235a6fff958e9a060379>>
10+
* @generated SignedSource<<e63a489a1e565aeee1f75d2c73cea4a1>>
1111
*/
1212

1313
"use strict";
@@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) {
203203
exports.useFormStatus = function () {
204204
return ReactSharedInternals.H.useHostTransitionStatus();
205205
};
206-
exports.version = "19.2.0-native-fb-d742611c-20250603";
206+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<1c5268d0cdf7f429f32642769d23efbd>>
10+
* @generated SignedSource<<74c063fdd431e982424ee3a1755935fd>>
1111
*/
1212

1313
/*
@@ -27055,11 +27055,11 @@ __DEV__ &&
2705527055
};
2705627056
(function () {
2705727057
var isomorphicReactPackageVersion = React.version;
27058-
if ("19.2.0-native-fb-d742611c-20250603" !== isomorphicReactPackageVersion)
27058+
if ("19.2.0-native-fb-911dbd9e-20250609" !== isomorphicReactPackageVersion)
2705927059
throw Error(
2706027060
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2706127061
(isomorphicReactPackageVersion +
27062-
"\n - react-dom: 19.2.0-native-fb-d742611c-20250603\nLearn more: https://react.dev/warnings/version-mismatch")
27062+
"\n - react-dom: 19.2.0-native-fb-911dbd9e-20250609\nLearn more: https://react.dev/warnings/version-mismatch")
2706327063
);
2706427064
})();
2706527065
("function" === typeof Map &&
@@ -27096,10 +27096,10 @@ __DEV__ &&
2709627096
!(function () {
2709727097
var internals = {
2709827098
bundleType: 1,
27099-
version: "19.2.0-native-fb-d742611c-20250603",
27099+
version: "19.2.0-native-fb-911dbd9e-20250609",
2710027100
rendererPackageName: "react-dom",
2710127101
currentDispatcherRef: ReactSharedInternals,
27102-
reconcilerVersion: "19.2.0-native-fb-d742611c-20250603"
27102+
reconcilerVersion: "19.2.0-native-fb-911dbd9e-20250609"
2710327103
};
2710427104
internals.overrideHookState = overrideHookState;
2710527105
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27237,5 +27237,5 @@ __DEV__ &&
2723727237
listenToAllSupportedEvents(container);
2723827238
return new ReactDOMHydrationRoot(initialChildren);
2723927239
};
27240-
exports.version = "19.2.0-native-fb-d742611c-20250603";
27240+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";
2724127241
})();

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<f938b786e9eaf90a682fa1a018b0eece>>
10+
* @generated SignedSource<<3c71f910e9903c5be1729efa33016f70>>
1111
*/
1212

1313
/*
@@ -17101,14 +17101,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1710117101
};
1710217102
var isomorphicReactPackageVersion$jscomp$inline_2017 = React.version;
1710317103
if (
17104-
"19.2.0-native-fb-d742611c-20250603" !==
17104+
"19.2.0-native-fb-911dbd9e-20250609" !==
1710517105
isomorphicReactPackageVersion$jscomp$inline_2017
1710617106
)
1710717107
throw Error(
1710817108
formatProdErrorMessage(
1710917109
527,
1711017110
isomorphicReactPackageVersion$jscomp$inline_2017,
17111-
"19.2.0-native-fb-d742611c-20250603"
17111+
"19.2.0-native-fb-911dbd9e-20250609"
1711217112
)
1711317113
);
1711417114
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17130,10 +17130,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1713017130
};
1713117131
var internals$jscomp$inline_2536 = {
1713217132
bundleType: 0,
17133-
version: "19.2.0-native-fb-d742611c-20250603",
17133+
version: "19.2.0-native-fb-911dbd9e-20250609",
1713417134
rendererPackageName: "react-dom",
1713517135
currentDispatcherRef: ReactSharedInternals,
17136-
reconcilerVersion: "19.2.0-native-fb-d742611c-20250603"
17136+
reconcilerVersion: "19.2.0-native-fb-911dbd9e-20250609"
1713717137
};
1713817138
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1713917139
var hook$jscomp$inline_2537 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17231,4 +17231,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1723117231
listenToAllSupportedEvents(container);
1723217232
return new ReactDOMHydrationRoot(initialChildren);
1723317233
};
17234-
exports.version = "19.2.0-native-fb-d742611c-20250603";
17234+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<d81ca51c17b4bf0dcee0ea3df4199bb3>>
10+
* @generated SignedSource<<9fd8f5f512d50f839d908cb55b11f702>>
1111
*/
1212

1313
/*
@@ -17811,14 +17811,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1781117811
};
1781217812
var isomorphicReactPackageVersion$jscomp$inline_2120 = React.version;
1781317813
if (
17814-
"19.2.0-native-fb-d742611c-20250603" !==
17814+
"19.2.0-native-fb-911dbd9e-20250609" !==
1781517815
isomorphicReactPackageVersion$jscomp$inline_2120
1781617816
)
1781717817
throw Error(
1781817818
formatProdErrorMessage(
1781917819
527,
1782017820
isomorphicReactPackageVersion$jscomp$inline_2120,
17821-
"19.2.0-native-fb-d742611c-20250603"
17821+
"19.2.0-native-fb-911dbd9e-20250609"
1782217822
)
1782317823
);
1782417824
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17840,10 +17840,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1784017840
};
1784117841
var internals$jscomp$inline_2127 = {
1784217842
bundleType: 0,
17843-
version: "19.2.0-native-fb-d742611c-20250603",
17843+
version: "19.2.0-native-fb-911dbd9e-20250609",
1784417844
rendererPackageName: "react-dom",
1784517845
currentDispatcherRef: ReactSharedInternals,
17846-
reconcilerVersion: "19.2.0-native-fb-d742611c-20250603",
17846+
reconcilerVersion: "19.2.0-native-fb-911dbd9e-20250609",
1784717847
getLaneLabelMap: function () {
1784817848
for (
1784917849
var map = new Map(), lane = 1, index$313 = 0;
@@ -17956,4 +17956,4 @@ exports.hydrateRoot = function (container, initialChildren, options) {
1795617956
listenToAllSupportedEvents(container);
1795717957
return new ReactDOMHydrationRoot(initialChildren);
1795817958
};
17959-
exports.version = "19.2.0-native-fb-d742611c-20250603";
17959+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<5248d2aa70fc7a785cdc31862fc337e6>>
10+
* @generated SignedSource<<1551deabbef3877cd90e0b3853dd8bd9>>
1111
*/
1212

1313
/*
@@ -27111,11 +27111,11 @@ __DEV__ &&
2711127111
};
2711227112
(function () {
2711327113
var isomorphicReactPackageVersion = React.version;
27114-
if ("19.2.0-native-fb-d742611c-20250603" !== isomorphicReactPackageVersion)
27114+
if ("19.2.0-native-fb-911dbd9e-20250609" !== isomorphicReactPackageVersion)
2711527115
throw Error(
2711627116
'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' +
2711727117
(isomorphicReactPackageVersion +
27118-
"\n - react-dom: 19.2.0-native-fb-d742611c-20250603\nLearn more: https://react.dev/warnings/version-mismatch")
27118+
"\n - react-dom: 19.2.0-native-fb-911dbd9e-20250609\nLearn more: https://react.dev/warnings/version-mismatch")
2711927119
);
2712027120
})();
2712127121
("function" === typeof Map &&
@@ -27152,10 +27152,10 @@ __DEV__ &&
2715227152
!(function () {
2715327153
var internals = {
2715427154
bundleType: 1,
27155-
version: "19.2.0-native-fb-d742611c-20250603",
27155+
version: "19.2.0-native-fb-911dbd9e-20250609",
2715627156
rendererPackageName: "react-dom",
2715727157
currentDispatcherRef: ReactSharedInternals,
27158-
reconcilerVersion: "19.2.0-native-fb-d742611c-20250603"
27158+
reconcilerVersion: "19.2.0-native-fb-911dbd9e-20250609"
2715927159
};
2716027160
internals.overrideHookState = overrideHookState;
2716127161
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -27609,7 +27609,7 @@ __DEV__ &&
2760927609
exports.useFormStatus = function () {
2761027610
return resolveDispatcher().useHostTransitionStatus();
2761127611
};
27612-
exports.version = "19.2.0-native-fb-d742611c-20250603";
27612+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";
2761327613
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2761427614
"function" ===
2761527615
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b265df1a9c72f7548dc6c39cb6eac48d>>
10+
* @generated SignedSource<<b9686bc8f6d76906c2b4f89ebbe6d3b9>>
1111
*/
1212

1313
/*
@@ -17112,14 +17112,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1711217112
};
1711317113
var isomorphicReactPackageVersion$jscomp$inline_2018 = React.version;
1711417114
if (
17115-
"19.2.0-native-fb-d742611c-20250603" !==
17115+
"19.2.0-native-fb-911dbd9e-20250609" !==
1711617116
isomorphicReactPackageVersion$jscomp$inline_2018
1711717117
)
1711817118
throw Error(
1711917119
formatProdErrorMessage(
1712017120
527,
1712117121
isomorphicReactPackageVersion$jscomp$inline_2018,
17122-
"19.2.0-native-fb-d742611c-20250603"
17122+
"19.2.0-native-fb-911dbd9e-20250609"
1712317123
)
1712417124
);
1712517125
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17141,10 +17141,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1714117141
};
1714217142
var internals$jscomp$inline_2539 = {
1714317143
bundleType: 0,
17144-
version: "19.2.0-native-fb-d742611c-20250603",
17144+
version: "19.2.0-native-fb-911dbd9e-20250609",
1714517145
rendererPackageName: "react-dom",
1714617146
currentDispatcherRef: ReactSharedInternals,
17147-
reconcilerVersion: "19.2.0-native-fb-d742611c-20250603"
17147+
reconcilerVersion: "19.2.0-native-fb-911dbd9e-20250609"
1714817148
};
1714917149
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1715017150
var hook$jscomp$inline_2540 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -17395,4 +17395,4 @@ exports.useFormState = function (action, initialState, permalink) {
1739517395
exports.useFormStatus = function () {
1739617396
return ReactSharedInternals.H.useHostTransitionStatus();
1739717397
};
17398-
exports.version = "19.2.0-native-fb-d742611c-20250603";
17398+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<f130682193151591520c7a3335b752c0>>
10+
* @generated SignedSource<<8fcd9a7f75aaa841953faef37ccfc789>>
1111
*/
1212

1313
/*
@@ -17826,14 +17826,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) {
1782617826
};
1782717827
var isomorphicReactPackageVersion$jscomp$inline_2121 = React.version;
1782817828
if (
17829-
"19.2.0-native-fb-d742611c-20250603" !==
17829+
"19.2.0-native-fb-911dbd9e-20250609" !==
1783017830
isomorphicReactPackageVersion$jscomp$inline_2121
1783117831
)
1783217832
throw Error(
1783317833
formatProdErrorMessage(
1783417834
527,
1783517835
isomorphicReactPackageVersion$jscomp$inline_2121,
17836-
"19.2.0-native-fb-d742611c-20250603"
17836+
"19.2.0-native-fb-911dbd9e-20250609"
1783717837
)
1783817838
);
1783917839
ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
@@ -17855,10 +17855,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) {
1785517855
};
1785617856
var internals$jscomp$inline_2128 = {
1785717857
bundleType: 0,
17858-
version: "19.2.0-native-fb-d742611c-20250603",
17858+
version: "19.2.0-native-fb-911dbd9e-20250609",
1785917859
rendererPackageName: "react-dom",
1786017860
currentDispatcherRef: ReactSharedInternals,
17861-
reconcilerVersion: "19.2.0-native-fb-d742611c-20250603",
17861+
reconcilerVersion: "19.2.0-native-fb-911dbd9e-20250609",
1786217862
getLaneLabelMap: function () {
1786317863
for (
1786417864
var map = new Map(), lane = 1, index$313 = 0;
@@ -18124,7 +18124,7 @@ exports.useFormState = function (action, initialState, permalink) {
1812418124
exports.useFormStatus = function () {
1812518125
return ReactSharedInternals.H.useHostTransitionStatus();
1812618126
};
18127-
exports.version = "19.2.0-native-fb-d742611c-20250603";
18127+
exports.version = "19.2.0-native-fb-911dbd9e-20250609";
1812818128
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1812918129
"function" ===
1813018130
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)