MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / isMounted

Function isMounted

code/new-context-api/public/app.js:4509–4525  ·  view source on GitHub ↗
(component)

Source from the content-addressed store, hash-verified

4507}
4508
4509function isMounted(component) {
4510 {
4511 var owner = ReactCurrentOwner.current;
4512 if (owner !== null && owner.tag === ClassComponent) {
4513 var ownerFiber = owner;
4514 var instance = ownerFiber.stateNode;
4515 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');
4516 instance._warnedAboutRefsInRender = true;
4517 }
4518 }
4519
4520 var fiber = get(component);
4521 if (!fiber) {
4522 return false;
4523 }
4524 return isFiberMountedImpl(fiber) === MOUNTED;
4525}
4526
4527function assertIsMounted(fiber) {
4528 !(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