Skip to content
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

Merged
merged 4 commits into from
Nov 2, 2018

Conversation

youknowriad
Copy link
Contributor

This PR removes findDOMNode usage from the block wrapper component by leveraging forwardRef for the IgnoreNestedEvents component as we only want to reference its inner DOM Node.

@youknowriad youknowriad added the [Type] Code Quality Issues or PRs that relate to code quality label Oct 28, 2018
@youknowriad youknowriad self-assigned this Oct 28, 2018
@youknowriad youknowriad requested a review from a team October 28, 2018 09:53
@aduth
Copy link
Member

aduth commented Oct 30, 2018

Test failures here appear legitimate.

@youknowriad youknowriad force-pushed the remove/find-dom-node-block branch 2 times, most recently from c54c094 to ce4bd54 Compare November 1, 2018 10:45
@youknowriad youknowriad mentioned this pull request Nov 1, 2018
12 tasks
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a 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 ) => {
Copy link
Member

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 );
Copy link
Member

@jorgefilipecosta jorgefilipecosta Nov 1, 2018

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 ) {
Copy link
Member

@jorgefilipecosta jorgefilipecosta Nov 1, 2018

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.

Copy link
Contributor Author

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.

@youknowriad youknowriad merged commit d3d6f93 into master Nov 2, 2018
@youknowriad youknowriad deleted the remove/find-dom-node-block branch November 2, 2018 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants