Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Accessing native element #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ export default function (CustomElement, opts) {
static get displayName() {
return displayName;
}
getNativeElement() {
return this._elementNode;
}
componentDidMount() {
this._elementNode = ReactDOM.findDOMNode(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the same thing as what was happening before?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this change it is exposed. The scoped node element is not accessible outside the funciton before this change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@treshugart Can this be merged? This helps accessing the native element directly

Copy link
Contributor

@treshugart treshugart Aug 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess what I was wondering is that, if you can call comp.getNativeElement(), then you can call findDOMNode(comp) just as easily, no?

this.componentWillReceiveProps(this.props);
}
componentWillReceiveProps(props) {
const node = ReactDOM.findDOMNode(this);
const node = this.getNativeElement();
Object.keys(props).forEach(name => {
if (name === 'children' || name === 'style') {
return;
Expand Down