function checkComponentWillUnmountForTeardown(node) {
    if (node.key.name !== "componentWillUnmount") {
      return;
    }
    const statements = node.value.body.body;
    const stateVariables = {};
    const componentId = _getParentComponentId(node);
    statements.forEach(statement => {
      const isTeardown = astHelpers.isAnimationTeardown(statement);
      const extractedState = _getStateExtraction(statement, stateVariables);
      if (extractedState) {
        stateVariables[extractedState.variable] = extractedState.property;
      }
      if (isTeardown) {
        const statePropertyName = astHelpers.getTornDownAnimationState(
          statement
        );
        // If we're directly tearing down from a state reference
        // (e.g. this.state.foo.stopAnimation(), mark it directly.
        if (statePropertyName) {
          const componentAnimations = activeAnimations[componentId];
          if (componentAnimations) {
            delete activeAnimations[componentId][statePropertyName];
          }
        } else {
          // Otherwise, trace the variable to determine if it
          // corresponds to any of the variables extracted from state
          const torndownVariable = statement.expression.callee.object;
          const stateMatch = stateVariables[torndownVariable.name];
          if (torndownVariable.type === "Identifier" && stateMatch) {
            const componentAnimations = activeAnimations[componentId];
            if (componentAnimations) {
              delete activeAnimations[componentId][stateMatch];
            }
          }
        }
      }
    });
  }
/**
   * Checks for animation teardowns in componentWillUnmount
   */
Checks for animation teardowns in componentWillUnmount
Checks for animation teardowns in componentWillUnmount
function checkComponentWillUnmountForTeardown(node) {
    if (node.key.name !== "componentWillUnmount") {
      return;
    }
    const statements = node.value.body.body;
    const stateVariables = {};
    const componentId = _getParentComponentId(node);
    statements.forEach(statement => {
      const isTeardown = astHelpers.isAnimationTeardown(statement);
      const extractedState = _getStateExtraction(statement, stateVariables);
      if (extractedState) {
        stateVariables[extractedState.variable] = extractedState.property;
      }
      if (isTeardown) {
        const statePropertyName = astHelpers.getTornDownAnimationState(
          statement
        );
        if (statePropertyName) {
          const componentAnimations = activeAnimations[componentId];
          if (componentAnimations) {
            delete activeAnimations[componentId][statePropertyName];
          }
        } else {
          const torndownVariable = statement.expression.callee.object;
          const stateMatch = stateVariables[torndownVariable.name];
          if (torndownVariable.type === "Identifier" && stateMatch) {
            const componentAnimations = activeAnimations[componentId];
            if (componentAnimations) {
              delete activeAnimations[componentId][stateMatch];
            }
          }
        }
      }
    });
  }
function checkComponentWillUnmountForTeardown ( node ) { if ( node . key . name !== "componentWillUnmount" ) { return ; } const statements = node . value . body . body ; const stateVariables = { } ; const componentId = _getParentComponentId ( node ) ; statements . forEach ( statement => { const isTeardown = astHelpers . isAnimationTeardown ( statement ) ; const extractedState = _getStateExtraction ( statement , stateVariables ) ; if ( extractedState ) { stateVariables [ extractedState . variable ] = extractedState . property ; } if ( isTeardown ) { const statePropertyName = astHelpers . getTornDownAnimationState ( statement ) ; if ( statePropertyName ) { const componentAnimations = activeAnimations [ componentId ] ; if ( componentAnimations ) { delete activeAnimations [ componentId ] [ statePropertyName ] ; } } else { const torndownVariable = statement . expression . callee . object ; const stateMatch = stateVariables [ torndownVariable . name ] ; if ( torndownVariable . type === "Identifier" && stateMatch ) { const componentAnimations = activeAnimations [ componentId ] ; if ( componentAnimations ) { delete activeAnimations [ componentId ] [ stateMatch ] ; } } } } } ) ; }
Checks for animation teardowns in componentWillUnmount
Checks for animation teardowns in componentWillUnmount
// If we're directly tearing down from a state reference // (e.g. this.state.foo.stopAnimation(), mark it directly. // Otherwise, trace the variable to determine if it // corresponds to any of the variables extracted from state