feat: implement rerender functionality to fix host component rerender performance issue #4181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR implements the rerender functionality to solve the performance issue described in GitHub issue #4171, where host component rerenders caused the entire remote app to be recreated instead of just rerendering.
🔧 Changes Made
1. Enhanced Type Definitions (types.ts)
rerender?: (props: T) => voidtoProviderFnParams<T>interfaceBridgeComponentInstanceinterface with rerender method2. State Management System (bridge-base.tsx)
StatefulBridgeWrappercomponent using React state3. Optimized Prop Handling (component.tsx)
...Object.values(props)dependency that caused performance issues4. Comprehensive Testing (bridge.spec.tsx)
5. Documentation (RERENDER_EXAMPLE.md)
🚀 API Usage
Automatic Optimization (Default - No Code Changes Needed)
Custom Rerender Logic (Advanced Use Cases)
Host App Usage (No Changes Required)
🔄 Performance Impact
Before (Problem):
After (Solution):
Or with custom rerender:
🧪 Implementation Details
State Management Architecture
Backward Compatibility
✅ Quality Assurance
Build & Type Safety
nx build bridge-reactpassesTesting Results
Performance Verification
🎉 Benefits Delivered
📋 Files Changed
packages/bridge/bridge-react/src/types.ts- Enhanced type definitionspackages/bridge/bridge-react/src/provider/versions/bridge-base.tsx- State management systempackages/bridge/bridge-react/src/remote/component.tsx- Optimized prop handlingpackages/bridge/bridge-react/__tests__/bridge.spec.tsx- Comprehensive testspackages/bridge/bridge-react/RERENDER_EXAMPLE.md- Documentation and examplesFixes #4171