Skip to content

Commit

Permalink
fix for react native automatic jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Jan 18, 2025
1 parent 1fb49ff commit 395d14d
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions jsx-dev-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,35 @@ var WDYR = require('@welldone-software/why-did-you-render')
var origJsxDev = jsxDevRuntime.jsxDEV
var wdyrStore = WDYR.wdyrStore

module.exports = jsxDevRuntime
module.exports.jsxDEV = function jsxDEV(...args){
if (wdyrStore.React && wdyrStore.React.__IS_WDYR__) {
var origType = args[0]
var rest = args.slice(1)

var WDYRType = WDYR.getWDYRType(origType)
if (WDYRType) {
try {
wdyrStore.ownerBeforeElementCreation = WDYR.getCurrentOwner();
var element = origJsxDev.apply(null, [WDYRType].concat(rest))
if (wdyrStore.options.logOwnerReasons) {
WDYR.storeOwnerData(element)
}
return element
} catch(e) {
wdyrStore.options.consoleLog('whyDidYouRender JSX transform error. Please file a bug at https://github.com/welldone-software/why-did-you-render/issues.', {
errorInfo: {
error: e,
componentNameOrComponent: origType,
rest: rest,
options: wdyrStore.options
module.exports = {
...jsxDevRuntime,
jsxDEV(...args) {
if (wdyrStore.React && wdyrStore.React.__IS_WDYR__) {
var origType = args[0]
var rest = args.slice(1)

var WDYRType = WDYR.getWDYRType(origType)
if (WDYRType) {
try {
wdyrStore.ownerBeforeElementCreation = WDYR.getCurrentOwner();
var element = origJsxDev.apply(null, [WDYRType].concat(rest))
if (wdyrStore.options.logOwnerReasons) {
WDYR.storeOwnerData(element)
}
})
return element
} catch(e) {
wdyrStore.options.consoleLog('whyDidYouRender JSX transform error. Please file a bug at https://github.com/welldone-software/why-did-you-render/issues.', {
errorInfo: {
error: e,
componentNameOrComponent: origType,
rest: rest,
options: wdyrStore.options
}
})
}
}
}

return origJsxDev.apply(null, args)
}

return origJsxDev.apply(null, args)
}
};

0 comments on commit 395d14d

Please sign in to comment.