An Angular integration library for rendering React components inside Angular applications. Provides a bridge component, script loader, and debugging tools for embedding React-based UI within the MemberJunction Angular ecosystem.
Installation
npminstall@memberjunction/ng-react
Overview
This package provides a seamless bridge between Angular and React, allowing React components to be loaded and rendered within Angular templates. It handles React and ReactDOM script loading, Babel transpilation of JSX, component lifecycle management, and two-way communication between the Angular host and React guest.
flowchart TD
subgraph Angular["Angular Host"]
A["MJReactComponent"] -->|Props| B["ReactBridgeService"]
end
subgraph Bridge["Bridge Layer"]
B --> C["ScriptLoaderService"]
C --> D["Load React + ReactDOM + Babel"]
B --> E["AngularAdapterService"]
end
subgraph React["React Guest"]
D --> F["React Component"]
F -->|Events| E
E -->|Callbacks| A
end
style Angular fill:#2d6a9f,stroke:#1a4971,color:#fff
style Bridge fill:#7c5295,stroke:#563a6b,color:#fff
style React fill:#2d8659,stroke:#1a5c3a,color:#fff
Hosts that drive a component from outside (an agent operating it through a realtime channel, a toolbar) call the standard component methods on the MJReactComponent instance: InvokeMethod(name, ...args), HasMethod(name), GetCurrentDataState(), Refresh() (the component's own refresh() when it registered one, otherwise a re-render), Print(), validate(), IsDirty(), Reset(), ScrollTo(target) and Focus(target?). Each is a no-op (or undefined/false) until the component has initialized (Initialized fires). A new Component input is a new version: the component reinitializes in place and Initialized fires again.
Services
Service
Purpose
ScriptLoaderService
Loads React, ReactDOM, and Babel from CDN with caching
ReactBridgeService
Manages React component lifecycle and prop synchronization
AngularAdapterService
Provides Angular context (router, DI) to React components