MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / isMounted

Function isMounted

code/higher-order-components/public/app.js:5142–5158  ·  view source on GitHub ↗
(component)

Source from the content-addressed store, hash-verified

5140}
5141
5142function isMounted(component) {
5143 {
5144 var owner = ReactCurrentOwner.current;
5145 if (owner !== null && owner.tag === ClassComponent) {
5146 var ownerFiber = owner;
5147 var instance = ownerFiber.stateNode;
5148 warning(instance._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', getComponentName(ownerFiber) || 'A component');
5149 instance._warnedAboutRefsInRender = true;
5150 }
5151 }
5152
5153 var fiber = get(component);
5154 if (!fiber) {
5155 return false;
5156 }
5157 return isFiberMountedImpl(fiber) === MOUNTED;
5158}
5159
5160function assertIsMounted(fiber) {
5161 !(isFiberMountedImpl(fiber) === MOUNTED) ? invariant(false, 'Unable to find node on an unmounted component.') : void 0;

Callers

nothing calls this directly

Calls 4

warningFunction · 0.85
getComponentNameFunction · 0.70
getFunction · 0.70
isFiberMountedImplFunction · 0.70

Tested by

no test coverage detected