-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Leverage forwardRef to remove findDOMNode from the block component #11170
Conversation
Test failures here appear legitimate. |
c54c094
to
ce4bd54
Compare
ce4bd54
to
acbb4d0
Compare
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.
Things looked fine in my tests 👍
} | ||
} | ||
|
||
export default IgnoreNestedEvents; | ||
export default forwardRef( ( props, ref ) => { |
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.
Should we add a displayName as we did in #11363?
this.wrapperNode = node; | ||
|
||
this.props.blockRef( node, this.props.clientId ); |
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.
Not related but something I noticed while reviewing. The parent passes the clientId and a callback function blockRef that receives the node and the clientId, passing the clientId here seems unnecessary the parent can pass a normal ref function blockRef specific for each cliendId.
this.wrapperNode = node; | ||
|
||
this.props.blockRef( node, this.props.clientId ); | ||
} | ||
|
||
bindBlockNode( node ) { |
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.
For this ref (bindBlockNode), it seems we can use createRef in the constructor. But I'm not sure if it is beneficial or has any advantage besides saving one or two lines of code.
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 think we can probably use forwardRef
in the Block
component to get directly the ref to the div here and use createRef
but Let's not change this in this PR.
acbb4d0
to
460acf9
Compare
This PR removes
findDOMNode
usage from the block wrapper component by leveragingforwardRef
for theIgnoreNestedEvents
component as we only want to reference its inner DOM Node.