From b1f66c8e7c1941d991633a2b7bfd3cd2595724c9 Mon Sep 17 00:00:00 2001 From: Avichay Eyal Date: Wed, 30 May 2018 01:21:37 +0300 Subject: [PATCH 1/2] Adding access to native element Use case: Accessing properties or attributes directly from the element. Problem: Impossible to access, event via refs, as it reaches the wrapper class only. --- src/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.js b/src/index.js index f5ea9c4..7c25122 100644 --- a/src/index.js +++ b/src/index.js @@ -43,10 +43,15 @@ export default function (CustomElement, opts) { static get displayName() { return displayName; } + getNativeElement() { + return this._elementNode; + } componentDidMount() { + this._elementNode = ReactDOM.findDOMNode(this); this.componentWillReceiveProps(this.props); } componentWillReceiveProps(props) { + const node = this.getNativeElement(); const node = ReactDOM.findDOMNode(this); Object.keys(props).forEach(name => { if (name === 'children' || name === 'style') { From 25bbde6dea1d8184c9f96f2dfdf04350afea0cea Mon Sep 17 00:00:00 2001 From: Avichay Eyal Date: Wed, 30 May 2018 01:22:35 +0300 Subject: [PATCH 2/2] Update index.js --- src/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/index.js b/src/index.js index 7c25122..5095b0d 100644 --- a/src/index.js +++ b/src/index.js @@ -52,7 +52,6 @@ export default function (CustomElement, opts) { } componentWillReceiveProps(props) { const node = this.getNativeElement(); - const node = ReactDOM.findDOMNode(this); Object.keys(props).forEach(name => { if (name === 'children' || name === 'style') { return;