MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / getNodeFromInstance

Function getNodeFromInstance

bundle.js:5645–5652  ·  view source on GitHub ↗

* Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding * DOM node.

(inst)

Source from the content-addressed store, hash-verified

5643 * Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
5644 * DOM node.
5645 */function getNodeFromInstance(inst){if(inst.tag===HostComponent||inst.tag===HostText){// In Fiber this, is just the state node right now. We assume it will be
5646// a host component or host text.
5647return inst.stateNode;}// Without this first invariant, passing a non-DOM-component triggers the next
5648// invariant for a missing parent, which is super confusing.
5649!(inst._hostNode!==undefined)?invariant(false,'getNodeFromInstance: Invalid argument.'):void 0;if(inst._hostNode){return inst._hostNode;}// Walk up the tree until we find an ancestor whose DOM node we have cached.
5650var parents=[];while(!inst._hostNode){parents.push(inst);!inst._hostParent?invariant(false,'React DOM tree root should always have a node reference.'):void 0;inst=inst._hostParent;}// Now parents contains each ancestor that does *not* have a cached native
5651// node, and `inst` is the deepest ancestor that does.
5652for(;parents.length;inst=parents.pop()){precacheChildNodes(inst,inst._hostNode);}return inst._hostNode;}function getFiberCurrentPropsFromNode(node){return node[internalEventHandlersKey]||null;}function updateFiberProps$1(node,props){node[internalEventHandlersKey]=props;}var ReactDOMComponentTree={getClosestInstanceFromNode:getClosestInstanceFromNode,getInstanceFromNode:getInstanceFromNode,getNodeFromInstance:getNodeFromInstance,precacheChildNodes:precacheChildNodes,precacheNode:precacheNode,uncacheNode:uncacheNode,precacheFiberNode:precacheFiberNode$1,getFiberCurrentPropsFromNode:getFiberCurrentPropsFromNode,updateFiberProps:updateFiberProps$1};var ReactDOMComponentTree_1=ReactDOMComponentTree;/**
5653 * Copyright (c) 2013-present, Facebook, Inc.
5654 *
5655 * This source code is licensed under the MIT license found in the

Callers

nothing calls this directly

Calls 2

precacheChildNodesFunction · 0.85
invariantFunction · 0.70

Tested by

no test coverage detected