# chooin/react-native-lifecycle architecture

> Architecture diagram of the GitHub repository chooin/react-native-lifecycle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chooin/react-native-lifecycle
- Repository: https://github.com/chooin/react-native-lifecycle

## Overview

##### Main Components Structure

a. Application Layer (Global Hooks)
- Their connection to React Native's AppState

b. Screen/Page Layer (Component Hooks)
- UseMount, useShow, useHide, useUnmount, and useResize
- Their connection to React Navigation

##### Component Relationships

- [React Native Core] ─────────────────────┐
- ↑                                │
- [React Navigation] ←──────────────┐      │
- ↑                         │      │
- [React Native Lifecycle Library]  │      │

- Global Hooks ────────┘      │

- useAppActive ─────────┘
- useAppInactive ───────┘

- Page/Screen Hooks

- useMount
- useShow
- useHide
- useUnmount
- useResize

##### Important Elements

a. Dependencies Section:
- React Navigation as a peer dependency
- Version compatibility (RN 0.65.0+ for v2.0.0+)

b. Hook Flow Section:
- How hooks interact with React Navigation and AppState

c. Event Propagation:
- How events flow from React Native core to the hooks
- Bi-directional communication where applicable

##### Technical Details to Highlight

- TypeScript implementation (shown by .ts files)
- Build pipeline (babel, jest, api-extractor)
- GitHub Actions integration for CI/CD
- Package distribution flow

Remember to include a small section showing the build and distribution pipeline, as indicated by the presence of build scripts and configuration files in the project structure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core
        RN[React Native Core]:::core
        RNav[React Navigation]:::navigation
    end

    subgraph Library["React Native Lifecycle Library"]
        Entry["Library Entry Point"]:::main
        
        subgraph Global["Global Hooks Layer"]
            AppActive["useAppActive Hook"]:::hook
            AppInactive["useAppInactive Hook"]:::hook
        end
        
        subgraph Screen["Screen/Page Hooks Layer"]
            Mount["useMount Hook"]:::hook
            Show["useShow Hook"]:::hook
            Hide["useHide Hook"]:::hook
            Unmount["useUnmount Hook"]:::hook
            Resize["useResize Hook"]:::hook
        end
        
        subgraph Infrastructure
            Build["Build Pipeline"]:::infra
            Test["Test Infrastructure"]:::infra
            CICD["CI/CD Pipeline"]:::infra
            TSConfig["TypeScript Config"]:::infra
        end
        
        subgraph Tests["Test Cases"]
            TestMount["Mount Tests"]:::test
            TestActive["App Active Tests"]:::test
            TestUnmount["Unmount Tests"]:::test
        end
    end
    
    RN --> RNav
    RNav --> Entry
    Entry --> Global
    Entry --> Screen
    
    AppActive --> RN
    AppInactive --> RN
    
    Mount & Show & Hide & Unmount & Resize --> RNav
    
    %% Click Events
    click AppActive "https://github.com/chooin/react-native-lifecycle/blob/master/src/useAppActive/index.ts"
    click AppInactive "https://github.com/chooin/react-native-lifecycle/blob/master/src/useAppInactive/index.ts"
    click Mount "https://github.com/chooin/react-native-lifecycle/blob/master/src/useMount/index.ts"
    click Show "https://github.com/chooin/react-native-lifecycle/blob/master/src/useShow/index.ts"
    click Hide "https://github.com/chooin/react-native-lifecycle/blob/master/src/useHide/index.ts"
    click Unmount "https://github.com/chooin/react-native-lifecycle/blob/master/src/useUnmount/index.ts"
    click Resize "https://github.com/chooin/react-native-lifecycle/blob/master/src/useResize/index.ts"
    click Build "https://github.com/chooin/react-native-lifecycle/blob/master/scripts/build.mjs"
    click Test "https://github.com/chooin/react-native-lifecycle/blob/master/jest.config.js"
    click CICD "https://github.com/chooin/react-native-lifecycle/blob/master/.github/workflows/test.yml"
    click Entry "https://github.com/chooin/react-native-lifecycle/blob/master/src/index.ts"
    click TSConfig "https://github.com/chooin/react-native-lifecycle/blob/master/tsconfig.json"
    click TestMount "https://github.com/chooin/react-native-lifecycle/blob/master/src/useMount/__tests__/useMount.test.ts"
    click TestActive "https://github.com/chooin/react-native-lifecycle/blob/master/src/useAppActive/__tests__/useAppActive.test.ts"
    click TestUnmount "https://github.com/chooin/react-native-lifecycle/blob/master/src/useUnmount/__tests__/useUnmount.test.ts"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef navigation fill:#e67e22,stroke:#d35400,color:white
    classDef hook fill:#2ecc71,stroke:#27ae60,color:white
    classDef main fill:#9b59b6,stroke:#8e44ad,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#f1c40f,stroke:#f39c12,color:white

    %% Legend
    subgraph Legend
        L1[React Native Core]:::core
        L2[React Navigation]:::navigation
        L3[Hooks]:::hook
        L4[Main Entry]:::main
        L5[Infrastructure]:::infra
        L6[Tests]:::test
    end
```
