chore: React-Native new architecture support along with old architecture#520
chore: React-Native new architecture support along with old architecture#520vivekshindhe wants to merge 2 commits intomasterfrom
Conversation
Implements dual architecture pattern supporting both legacy bridge and new TurboModule/Fabric architecture with zero configuration required. Restructures sample apps to demonstrate all supported configurations. Architecture changes: - Android: Split source sets (newarch/oldarch) with shared RazorpayModuleImpl - iOS: Updated to .mm files with conditional TurboModule protocol conformance - JS: Auto-detection of architecture at runtime with graceful fallback - Added TypeScript TurboModule specs and type definitions Sample apps reorganization: - Removed legacy example/SampleApp - Added sampleApps/NewArchSample: React Native 0.76 with new architecture - Added sampleApps/OldArch: React Native 0.68 with legacy bridge - Added sampleApps/Expo54Sample: Expo 54 integration example
- Remove hardcoded Folly version from podspec for broader RN version compatibility - Add iOS codegen output configuration to package.json - Replace OldArch sample (RN 0.66.5) with RN 0.68.0 example for better tooling compatibility - Update Expo54Sample with new architecture enabled (RCT_NEW_ARCH_ENABLED=1) - Add testID props to payment buttons in sample apps for E2E testing - Add Razorpay payment integration to Expo54Sample - Update NewArchSample with production test key - Update .gitignore for E2E test artifacts - Add gradle.properties for Android configuration Breaking changes: None - backward compatible with existing integrations Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" | ||
| integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== | ||
|
|
||
| fast-xml-parser@^4.4.1: |
There was a problem hiding this comment.
High severity vulnerability may affect your project—review required:
Line 3290 lists a dependency (fast-xml-parser) with a known High severity vulnerability.
ℹ️ Why this matters
Affected versions of fast-xml-parser are vulnerable to Improper Restriction of Recursive Entity References in DTDs ('XML Entity Expansion'). fast-xml-parser can be denial-of-service'd via uncontrolled XML entity expansion: a crafted XML document with a DOCTYPE that defines a large plain-text entity and references it many times causes OrderedObjParser.replaceEntitiesValue() to repeatedly expand the entity without any limit on output size or replacement work, blocking the Node.js event loop and freezing the application while parsing untrusted XML (mitigate by disabling entity/DOCTYPE processing, e.g., processEntities: false).
To resolve this comment:
Check if you are using fxparser on the CLI.
- If you're affected, upgrade this dependency to at least version 4.5.4 at sampleApps/NewArchSample/yarn.lock.
- If you're not affected, comment
/fp we don't use this [condition]
💬 Ignore this finding
To ignore this, reply with:
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
You can view more details on this finding in the Semgrep AppSec Platform here.
| resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" | ||
| integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== | ||
|
|
||
| fast-xml-parser@^4.4.1: |
There was a problem hiding this comment.
Critical severity vulnerability may affect your project—review required:
Line 3290 lists a dependency (fast-xml-parser) with a known Critical severity vulnerability.
ℹ️ Why this matters
Affected versions of fast-xml-parser are vulnerable to Incorrect Regular Expression. fast-xml-parser is vulnerable to an entity-encoding bypass when parsing untrusted XML with DOCTYPE entities enabled (the default processEntities: true): attacker-controlled DOCTYPE entity names are interpolated into RegExp() without escaping . (dot), so a name like l. becomes a wildcard regex that shadows built-in entities such as <, >, &, ", and ', allowing arbitrary replacement text and leading to XSS (or other injection) when the parsed output is later rendered or used in an injection-sensitive context.
To resolve this comment:
Check if you are using fxparser on the CLI.
- If you're affected, upgrade this dependency to at least version 4.5.4 at sampleApps/NewArchSample/yarn.lock.
- If you're not affected, comment
/fp we don't use this [condition]
💬 Ignore this finding
To ignore this, reply with:
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
You can view more details on this finding in the Semgrep AppSec Platform here.
There was a problem hiding this comment.
/fp we don't use this. This is a sample app, and it must have been added by a third party dependency. Not related to our react-native package.
| * Sends an event to JavaScript layer via DeviceEventEmitter. | ||
| * This works in both old and new architecture. | ||
| */ | ||
| private void sendEvent(String eventName, WritableMap params) { |
There was a problem hiding this comment.
Uses legacy getJSModule(RCTDeviceEventEmitter). Please confirm that in new-arch builds events still reach JS if not, we may need a different API for new arch
| let RazorpayCheckoutModule; | ||
| let RazorpayEventEmitterModule; | ||
|
|
||
| if (isTurboModuleEnabled) { |
There was a problem hiding this comment.
Good runtime check and fallback. Please confirm both old and new arch paths are tested so we don’t regress either.
| "url": "git+https://github.com/razorpay/react-native-razorpay.git" | ||
| }, | ||
| "codegenConfig": { | ||
| "name": "RNRazorpayCheckoutSpec", |
There was a problem hiding this comment.
Spec name inconsistency , Config says: RNRazorpayCheckoutSpec
Android codegen expects: NativeRazorpayCheckoutSpec please verify
Summary
This PR improves the react-native-razorpay package's compatibility across different React Native versions and architectures, and adds infrastructure for automated testing.
Changes
🔧 Core Package Improvements
Remove Folly version hardcoding (
react-native-razorpay.podspec)2021.07.22.00, causing conflicts with different RN versionsAdd iOS codegen configuration (
package.json)ios.outputDirtocodegenConfigfor proper TurboModule code generation📱 Sample App Updates
OldArchSample (Replaced)
Expo54Sample
RCT_NEW_ARCH_ENABLED=1for iOS,newArchEnabled=truefor Android)testID="razorpay-pay-button"🧪 Testing Coverage
With these changes, the package is validated across:
🔍 Other Changes
.gitignorefor E2E test artifactsgradle.propertiesconfigurationValidation
All three sample apps have been manually tested:
Backward Compatibility
✅ Fully backward compatible
Related Issues
Resolves compatibility issues with: