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

Function isMounted

code/third-party/public/app.js:4381–4397  ·  view source on GitHub ↗
(component)

Source from the content-addressed store, hash-verified

4379}
4380
4381function isMounted(component) {
4382 {
4383 var owner = ReactCurrentOwner.current;
4384 if (owner !== null && owner.tag === ClassComponent) {
4385 var ownerFiber = owner;
4386 var instance = ownerFiber.stateNode;
4387 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');
4388 instance._warnedAboutRefsInRender = true;
4389 }
4390 }
4391
4392 var fiber = get(component);
4393 if (!fiber) {
4394 return false;
4395 }
4396 return isFiberMountedImpl(fiber) === MOUNTED;
4397}
4398
4399function assertIsMounted(fiber) {
4400 !(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