-
Notifications
You must be signed in to change notification settings - Fork 47.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Debug Frames to Enable Renderers to Provide Custom Logic #10105
Changes from all commits
52c7625
7127625
7ee0424
f850b59
8ca272d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js | ||
* gives source code refs for unknown prop warning (ssr) | ||
* gives source code refs for unknown prop warning for exact elements (ssr) | ||
* gives source code refs for unknown prop warning for exact elements in composition (ssr) | ||
* should suggest property name if available (ssr) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ describe('ReactComponentTreeHook', () => { | |
var ReactDOMServer; | ||
var ReactInstanceMap; | ||
var ReactComponentTreeHook; | ||
var ReactDebugCurrentFiber; | ||
var ReactComponentTreeTestUtils; | ||
|
||
beforeEach(() => { | ||
|
@@ -29,6 +30,7 @@ describe('ReactComponentTreeHook', () => { | |
ReactDOM = require('react-dom'); | ||
ReactDOMServer = require('react-dom/server'); | ||
ReactInstanceMap = require('ReactInstanceMap'); | ||
ReactDebugCurrentFiber = require('ReactDebugCurrentFiber'); | ||
ReactComponentTreeHook = require('ReactComponentTreeHook'); | ||
ReactComponentTreeTestUtils = require('ReactComponentTreeTestUtils'); | ||
}); | ||
|
@@ -37,7 +39,9 @@ describe('ReactComponentTreeHook', () => { | |
describe('stack addenda', () => { | ||
it('gets created', () => { | ||
function getAddendum(element) { | ||
var addendum = ReactComponentTreeHook.getCurrentStackAddendum(element); | ||
var addendum = ReactDOMFeatureFlags.useFiber | ||
? ReactDebugCurrentFiber.getCurrentFiberStackAddendum() || '' | ||
: ReactComponentTreeHook.getCurrentStackAddendum(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This stack doesn't have the top frame (the next element rather than the component stack we're currently in), which the real warnings do, which is why the tests below can't be tested this way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests should probably be rewritten in terms of public API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thanks for clarifying. |
||
return addendum.replace(/\(at .+?:\d+\)/g, '(at **)'); | ||
} | ||
|
||
|
@@ -47,23 +51,23 @@ describe('ReactComponentTreeHook', () => { | |
Object.defineProperty(Anon, 'name', { | ||
value: null, | ||
}); | ||
function Orange() { | ||
return null; | ||
} | ||
// function Orange() { | ||
// return null; | ||
// } | ||
|
||
expectDev(getAddendum()).toBe(''); | ||
expectDev(getAddendum(<div />)).toBe('\n in div (at **)'); | ||
expectDev(getAddendum(<Anon />)).toBe('\n in Unknown (at **)'); | ||
expectDev(getAddendum(<Orange />)).toBe('\n in Orange (at **)'); | ||
expectDev(getAddendum(React.createElement(Orange))).toBe( | ||
'\n in Orange', | ||
); | ||
// expectDev(getAddendum(<div />)).toBe('\n in div (at **)'); | ||
// expectDev(getAddendum(<Anon />)).toBe('\n in Unknown (at **)'); | ||
// expectDev(getAddendum(<Orange />)).toBe('\n in Orange (at **)'); | ||
// expectDev(getAddendum(React.createElement(Orange))).toBe( | ||
// '\n in Orange', | ||
// ); | ||
|
||
var renders = 0; | ||
var rOwnedByQ; | ||
//var rOwnedByQ; | ||
|
||
function Q() { | ||
return (rOwnedByQ = React.createElement(R)); | ||
return /*rOwnedByQ =*/ React.createElement(R); | ||
} | ||
function R() { | ||
return <div><S /></div>; | ||
|
@@ -82,15 +86,15 @@ describe('ReactComponentTreeHook', () => { | |
'\n in Q (at **)', | ||
); | ||
expectDev(getAddendum(<span />)).toBe( | ||
'\n in span (at **)' + | ||
'\n in S (at **)' + | ||
// '\n in span (at **)' + | ||
'\n in S (at **)' + | ||
'\n in div (at **)' + | ||
'\n in R (created by Q)' + | ||
'\n in Q (at **)', | ||
); | ||
expectDev(getAddendum(React.createElement('span'))).toBe( | ||
'\n in span (created by S)' + | ||
'\n in S (at **)' + | ||
// '\n in span (created by S)' + | ||
'\n in S (at **)' + | ||
'\n in div (at **)' + | ||
'\n in R (created by Q)' + | ||
'\n in Q (at **)', | ||
|
@@ -103,7 +107,7 @@ describe('ReactComponentTreeHook', () => { | |
expectDev(renders).toBe(2); | ||
|
||
// Make sure owner is fetched for the top element too. | ||
expectDev(getAddendum(rOwnedByQ)).toBe('\n in R (created by Q)'); | ||
// expectDev(getAddendum(rOwnedByQ)).toBe('\n in R (created by Q)'); | ||
}); | ||
|
||
// These are features and regression tests that only affect | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add this. It was causing the build to fail because I now depend on shared code (describeComponentFrame) instead of shared global state.