-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[core] Enable innerRef on Backdrop, List, MenuList and Paper #13722
Merged
eps1lon
merged 12 commits into
mui:next
from
eps1lon:feat/core/forward-refs-in-function-components
Feb 1, 2019
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
abc6bfb
[core] Add testRef test util
eps1lon 0fc7609
[core] Add support for innerRef to critical components
eps1lon a850bfe
[docs] Fix component definition not found for forwardRef component
eps1lon 960cb3e
[core] Remove lint exception for named function callbacks
eps1lon f386ea2
[core] Fix size limit build error
eps1lon 59cb0a0
[core] Fix next failing on React.forwardRef
eps1lon 402c011
[core] Switch back to stable next
eps1lon fbf77f3
Merge branch 'master' into feat/core/forward-refs-in-function-components
eps1lon 094af1f
[docs] Fix size limit
eps1lon dc5ce5b
Merge branch 'master' into feat/core/forward-refs-in-function-components
eps1lon 5ec0216
[docs] use official react-docgen release
eps1lon 1984ae7
[core] adjust size limit from last merge
eps1lon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
import React from 'react'; | ||
import { assert } from 'chai'; | ||
import { createShallow, getClasses } from '@material-ui/core/test-utils'; | ||
import { createMount, createShallow, getClasses, testRef } from '@material-ui/core/test-utils'; | ||
import Backdrop from './Backdrop'; | ||
|
||
describe('<Backdrop />', () => { | ||
let mount; | ||
let shallow; | ||
let classes; | ||
|
||
before(() => { | ||
mount = createMount(); | ||
shallow = createShallow({ dive: true }); | ||
classes = getClasses(<Backdrop open />); | ||
}); | ||
|
||
after(() => { | ||
mount.cleanUp(); | ||
}); | ||
|
||
it('should render a backdrop div', () => { | ||
const wrapper = shallow(<Backdrop open className="woofBackdrop" />); | ||
assert.strictEqual(wrapper.childAt(0).hasClass('woofBackdrop'), true); | ||
assert.strictEqual(wrapper.childAt(0).hasClass(classes.root), true); | ||
}); | ||
|
||
it('does forward refs', () => { | ||
testRef(<Backdrop open />, mount); | ||
}); | ||
}); |
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import * as React from 'react'; | ||
import createMount from './createMount'; | ||
|
||
/** | ||
* Utility method to make assertions about the ref on an element | ||
* @param onRef - Make your assertions here | ||
*/ | ||
export default function testRef<T>( | ||
element: React.ReactElement<{ innerRef: React.RefObject<T> }>, | ||
mount: ReturnType<typeof createMount>, | ||
onRef: (ref: T) => void, | ||
): void; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { assert } from 'chai'; | ||
|
||
function assertDOMNode(node) { | ||
// duck typing a DOM node | ||
assert.ok(node.nodeName); | ||
} | ||
|
||
/** | ||
* | ||
* @param {React.ReactElement} element - The element should have a component wrapped | ||
* in withStyles as the root | ||
* @param {function} mount - Should be returnvalue of createMount | ||
* @param {function} onRef - Callback, first arg is the ref. | ||
* Assert that the ref is a DOM node by default | ||
*/ | ||
export default function testRef(element, mount, onRef = assertDOMNode) { | ||
const ref = React.createRef(); | ||
mount(<>{React.cloneElement(element, { innerRef: ref })}</>); | ||
onRef(ref.current); | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
See facebook/react#14319 for full explanation.