Skip to content

Commit

Permalink
fix: remove workaround for react issue (upgrading react@next)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Mar 1, 2023
1 parent a719938 commit a5076f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 75 deletions.
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"highlight.js": "^11.7.0",
"lowlight": "^2.8.0",
"next": "^13.1.5",
"react": "^18.3.0-next-ee8509801-20230117",
"react-dom": "^18.3.0-next-ee8509801-20230117",
"react": "^18.3.0-next-41110021f-20230301",
"react-dom": "^18.3.0-next-41110021f-20230301",
"style9": "^0.16.1",
"swr": "^2.0.1"
},
Expand Down
50 changes: 0 additions & 50 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,6 @@ export default function MyDocument() {
} catch (e) {}
})(localStorage, document)
*/}
{process.env.NODE_ENV !== 'production' && <script
dangerouslySetInnerHTML={{
__html: `
/**
* !!WARNING!!
* TEMPORARILY WORKAROUND A REACT DEVTOOLS ISSUE https://github.com/facebook/react/issues/25994
* REMOVE AFTER THE ISSUE IS FIXED
*/
// Save the original __REACT_DEVTOOLS_GLOBAL_HOOK__.inject
const reactDevToolsHookInject = window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject;
// Override the original __REACT_DEVTOOLS_GLOBAL_HOOK__.inject
// This will allow us to intercept and modify incoming injectProfilingHooks
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function inject(...args) {
const newArgs = args.map(arg => {
// Only modify the original arguments when injectProfilingHooks is present
if (!arg || !arg.injectProfilingHooks) return arg;
const { injectProfilingHooks: originalInjectProfilingHooks, ...rest } = arg;
return {
// Override the original injectProfilingHooks
// This will allow us to intercept and modify incoming hooks
injectProfilingHooks(...hooks) {
const newHooks = hooks.map(hook => {
// Only modify the original hooks when markComponentSuspended is present
if (!hook || !hook.markComponentSuspended) return hook;
// Override the original markComponentSuspended from the hook
const { markComponentSuspended: orignalMarkComponentSuspended, ...rest2 } = hook;
return {
markComponentSuspended(fiber, wakeable, lanes) {
if (typeof wakeable.then === 'function') {
return orignalMarkComponentSuspended.call(this, fiber, wakeable, lanes);
} else {
// If "wakeable.then" is not a function, log a warning.
console.warn('React DevTools issue detected and mitigated!\\nSee https://github.com/facebook/react/issues/25994 for more information.', { fiber, wakeable, lanes });
}
},
...rest2
};
});
originalInjectProfilingHooks.apply(this, newHooks);
},
...rest
};
});
return reactDevToolsHookInject.apply(this, newArgs);
};
`
}}
/>}
<script dangerouslySetInnerHTML={{ __html: '!function(b,c){try{var a=b["user-color-scheme"];a&&c.classList.add(a)}catch(d){}}(localStorage,document.documentElement)' }} />
</Head>
<body>
Expand Down

0 comments on commit a5076f3

Please sign in to comment.