Thank you for your interest in contributing to React Native Frame Capture! We welcome contributions of all kinds, from bug reports and documentation improvements to new features and performance enhancements.
Please take a moment to review this document to make the contribution process smooth and effective for everyone involved.
We want this community to be friendly and respectful to each other. Please follow our Code of Conduct in all your interactions with the project.
This project is a monorepo managed using Yarn workspaces. It contains the following packages:
- The library package in the root directory.
- An example app in the
example/directory.
To get started with the project, make sure you have the correct version of Node.js installed. See the .nvmrc file for the version used in this project.
Run yarn in the root directory to install the required dependencies for each package:
yarnSince the project relies on Yarn workspaces, you cannot use
npmfor development without manually migrating.
The example app demonstrates usage of the library. You need to run it to test any changes you make.
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
If you want to use Android Studio or Xcode to edit the native code, you can open the example/android or example/ios directories respectively in those editors. To edit the Objective-C or Swift files, open example/ios/FrameCaptureExample.xcworkspace in Xcode and find the source files at Pods > Development Pods > react-native-frame-capture.
To edit the Java or Kotlin files, open example/android in Android studio and find the source files at react-native-frame-capture under Android.
You can use various commands from the root directory to work with the project.
To start the packager:
yarn example startTo run the example app on Android:
yarn example androidTo run the example app on iOS:
yarn example iosTo confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
Running "FrameCaptureExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}Note the "fabric":true and "concurrentRoot":true properties.
Make sure your code passes TypeScript and ESLint. Run the following to verify:
yarn typecheck
yarn lintTo fix formatting errors, run the following:
yarn lint --fixRemember to add tests for your change if possible. Run the unit tests by:
yarn testWe follow the conventional commits specification for our commit messages:
fix: bug fixes, e.g. fix crash due to deprecated method.feat: new features, e.g. add new method to the module.refactor: code refactor, e.g. migrate from class components to hooks.docs: changes into documentation, e.g. add usage example for the module.test: adding or updating tests, e.g. add integration tests using detox.chore: tooling changes, e.g. change CI config.
Our pre-commit hooks verify that your commit message matches this format when committing.
We use TypeScript for type checking, ESLint with Prettier for linting and formatting the code, and Jest for testing.
Our pre-commit hooks verify that the linter and tests pass when committing.
We use release-it to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
To publish new versions, run the following:
yarn releaseThe package.json file contains various scripts for common tasks:
yarn: setup project by installing dependencies.yarn typecheck: type-check files with TypeScript.yarn lint: lint files with ESLint.yarn test: run unit tests with Jest.yarn example start: start the Metro server for the example app.yarn example android: run the example app on Android.yarn example ios: run the example app on iOS.
Understanding the project structure will help you navigate the codebase:
react-native-frame-capture/
├── src/ # TypeScript source code
│ ├── api.ts # Public API functions
│ ├── types.ts # TypeScript type definitions
│ ├── validation.ts # Input validation
│ ├── normalize.ts # Options normalization
│ ├── events.ts # Event handling
│ ├── errors.ts # Error classes
│ ├── constants.ts # Constants and defaults
│ ├── NativeFrameCapture.ts # TurboModule specification
│ └── index.tsx # Main entry point
├── android/ # Android native code
│ └── src/main/java/com/framecapture/
│ ├── FrameCaptureModule.kt # Main TurboModule implementation
│ ├── CaptureManager.kt # Core capture logic
│ ├── StorageManager.kt # Storage operations
│ ├── OverlayRenderer.kt # Overlay rendering
│ ├── ScreenCaptureService.kt # Foreground service
│ ├── Constants.kt # Native constants
│ ├── capture/ # Capture-related classes
│ ├── models/ # Data models and enums
│ ├── service/ # Service-related classes
│ ├── storage/ # Storage strategies
│ └── utils/ # Utility classes
├── example/ # Example React Native app
└── docs/ # Documentation (if any)
- Follow the existing code style (enforced by ESLint and Prettier)
- Add JSDoc comments for public APIs
- Export types for public interfaces
- Use strict TypeScript settings
- Avoid
anytypes when possible
- Follow Kotlin coding conventions
- Use data classes for models
- Prefer immutability where possible
- Add KDoc comments for public APIs
- Use meaningful variable and function names
- Handle errors gracefully with try-catch blocks
- Add unit tests for new features
- Update existing tests when modifying functionality
- Ensure all tests pass before submitting PR
- Test on multiple Android versions if possible (especially Android 5.0, 10, and 13+)
- Update README.md for new features or API changes
- Update CHANGELOG.md following Keep a Changelog format
- Add code examples for new features
- Update TypeScript type definitions
-
Enable Logcat filtering:
adb logcat | grep -E "CaptureManager|FrameCaptureModule|StorageManager"
-
Check MediaProjection permission:
adb shell dumpsys media_projection
-
Monitor storage:
adb shell df /data/data/com.yourapp/cache
-
View captured frames:
adb shell ls -la /data/data/com.yourapp/cache/captured_frames/
-
Build errors: Clean and rebuild
cd example/android && ./gradlew clean && cd ../.. yarn example android
-
Metro bundler issues: Reset cache
yarn example start --reset-cache
-
Native changes not reflecting: Rebuild the app
yarn example android
Working on your first pull request? You can learn how from this free series: How to Contribute to an Open Source Project on GitHub.
- Fork the repository and create your branch from
main - Install dependencies:
yarn - Make your changes following the guidelines above
- Test your changes thoroughly
- Run linters:
yarn lintandyarn typecheck - Run tests:
yarn test - Update documentation if needed
- Commit your changes following conventional commits
- Prefer small pull requests focused on one change
- Verify that linters and tests are passing
- Review the documentation to make sure it looks good
- Follow the pull request template when opening a pull request
- For API or implementation changes, discuss with maintainers first by opening an issue
- Add screenshots or videos for UI-related changes
- Reference related issues in your PR description
- Code follows the project's style guidelines
- Self-review of code completed
- Comments added for complex logic
- Documentation updated (README, CHANGELOG, etc.)
- Tests added/updated and passing
- Linters and type checks passing
- Tested on Android device/emulator
- No breaking changes (or clearly documented)
When reporting bugs, please include:
- Description: Clear description of the issue
- Steps to reproduce: Detailed steps to reproduce the behavior
- Expected behavior: What you expected to happen
- Actual behavior: What actually happened
- Environment:
- React Native version
- Android version
- Device/Emulator
- Library version
- Code sample: Minimal reproducible example
- Logs: Relevant error messages or logcat output
- Screenshots/Videos: If applicable
When requesting features, please include:
- Use case: Describe the problem you're trying to solve
- Proposed solution: How you envision the feature working
- Alternatives considered: Other solutions you've thought about
- Additional context: Any other relevant information
If you have questions about contributing, feel free to:
- Open a GitHub Discussion
- Open an issue with the
questionlabel - Check existing issues and discussions
By contributing to React Native Frame Capture, you agree that your contributions will be licensed under the MIT License.