Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/react-native-babel-plugin/src/actions/rum/tap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,19 @@ function handleMemoization(
? callback
: t.callExpression(callback, callArgs);

// Update handlerArgs in argsObject to match the actual callback params
// instead of the default [...args] computed from the outer identifier
const handlerArgsProp = argsObject.properties.find(
prop =>
t.isObjectProperty(prop) &&
t.isStringLiteral(prop.key) &&
prop.key.value === 'handlerArgs'
);

if (handlerArgsProp && t.isObjectProperty(handlerArgsProp)) {
handlerArgsProp.value = t.arrayExpression(callArgs);
}

const actionWrapper = getActionWrapperFunction(
t,
state,
Expand Down
14 changes: 7 additions & 7 deletions packages/react-native-babel-plugin/test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [event],
"componentName": "Pressable"
})(event);else return (event => {
console.log('Testing ', a, b, event);
Expand Down Expand Up @@ -1299,7 +1299,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [],
"componentName": "Pressable"
})();else return (() => {
console.log('Testing ');
Expand Down Expand Up @@ -1348,7 +1348,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [],
"componentName": "Pressable"
})();else return (() => {
console.log('Testing ');
Expand Down Expand Up @@ -1407,7 +1407,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [test],
"componentName": "Pressable"
})(test);else return funcN(test);
}, [a, b]);
Expand Down Expand Up @@ -1461,7 +1461,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [test],
"componentName": "Pressable"
})(test);else return funcN(test);
}, [a, b]);
Expand Down Expand Up @@ -1511,7 +1511,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [test],
"componentName": "Pressable"
})(test);else return funcN(test);
}, [a, b]);
Expand Down Expand Up @@ -1594,7 +1594,7 @@ describe('Babel plugin: wrap interaction handlers for RUM ( with memoization )',
"getContent": () => {
return __ddExtractText(<></>, []);
},
"handlerArgs": [...args],
"handlerArgs": [],
"componentName": "Pressable"
})();else return funcN();
}, []);
Expand Down
Loading