Created
May 23, 2023 15:27
-
-
Save brunos3d/1dfa176d39d2af5de75e8926478ae087 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const hrefMonkeyPatch = () => { | |
const originalCreateElement = React.createElement; | |
React.createElement = function createElement () { | |
const args = Array.prototype.slice.call(arguments); | |
if (!args[1]) { | |
args[1] = {}; | |
} | |
const element = args[0]; | |
const props = args[1]; | |
if (props?.['data-no-patch']) { | |
return originalCreateElement.apply(React, args); | |
} | |
if (element === 'a' && props.href) { | |
props.href += "?TESTE=TESTE"; | |
} | |
return originalCreateElement.apply(React, args); | |
}; | |
return () => { | |
React.createElement = originalCreateElement; | |
}; | |
}; | |
export default hrefMonkeyPatch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment