componentWillUnmount method

  1. @override
void componentWillUnmount()
override

Called when the component will unmount

Implementation

@override
void componentWillUnmount() {
  // Clean up hooks first
  for (final hook in _hooks) {
    hook.dispose();
  }
  _hooks.clear();

  // Clean up any remaining store subscriptions via StoreManager
  // This is a safety net in case hooks didn't clean up properly
  try {
    if (kDebugMode) {
      print('Cleaning up store subscriptions for component $instanceId');
    }
    // Note: StoreManager cleanup will be handled by individual hooks
  } catch (e) {
    if (kDebugMode) {
      print('Error during store cleanup: $e');
    }
  }

  _isMounted = false;
}