MCPcopy
hub / github.com/ctrlplusb/react-sizeme / handleDOMNode

Method handleDOMNode

src/with-size.js:222–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220 this.strategy === 'callback' ? this.callbackState : this.state
221
222 handleDOMNode() {
223 const found = this.element && ReactDOM.findDOMNode(this.element)
224
225 if (!found) {
226 // If we previously had a dom node then we need to ensure that
227 // we remove any existing listeners to avoid memory leaks.
228 this.uninstall()
229 return
230 }
231
232 if (!this.domEl) {
233 this.domEl = found
234 this.detector.listenTo(this.domEl, this.checkIfSizeChanged)
235 } else if (
236 (this.domEl.isSameNode && !this.domEl.isSameNode(found)) ||
237 this.domEl !== found
238 ) {
239 this.uninstall()
240 this.domEl = found
241 this.detector.listenTo(this.domEl, this.checkIfSizeChanged)
242 } else {
243 // Do nothing 👍
244 }
245 }
246
247 refCallback = (element) => {
248 this.element = element

Callers 2

componentDidMountMethod · 0.95
componentDidUpdateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected