Feat/add hook support#472
Merged
Merged
Conversation
Introduces a comprehensive React hooks API for secure storage, including new hooks in src/hooks.ts, shared utilities in src/hook-utils.ts, and error helpers in src/errors.ts. Updates the README with documentation and usage examples for the new hooks, adds a detailed HOOKS.md, and refactors the example app to use the new hooks-based API. Also updates ESLint config for improved compatibility and disables the 'import/extensions' rule.
Replaces Bun with Yarn for dependency management and scripts in Android, iOS, and release GitHub Actions workflows. Updates lockfile and Xcode project to reflect new dependency versions and NitroModules upgrade.
Changed the TypeScript compiler option 'noEmit' from false to true to prevent emitting output files during compilation. This is useful for type-checking only workflows.
Replaces legacy hooks implementation with modular, strongly-typed hooks in the src/hooks directory. Introduces a new core storage API in src/core/storage.ts and updates usage in example/App.tsx. Removes deprecated files and reorganizes internal modules for better maintainability. Adds babel-plugin-react-compiler to dev dependencies.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive React hooks API for react-native-sensitive-info, providing a modern, reactive interface with automatic memory management, loading states, and error handling. The implementation refactors the existing imperative API into a modular architecture while maintaining backward compatibility.
Key changes:
- Added six new React hooks (
useSecretItem,useSecret,useHasSecret,useSecureStorage,useSecurityAvailability,useSecureOperation) with automatic cleanup and memory leak prevention - Refactored core storage logic into a modular structure separating internal utilities, native bridge, and public API
- Migrated the example app from imperative API to hooks-based implementation
Reviewed Changes
Copilot reviewed 26 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/hooks/*.ts | New hook implementations with lifecycle management and async state handling |
| src/internal/*.ts | Extracted shared utilities for options normalization, native instance management, and error handling |
| src/core/storage.ts | Refactored imperative API with cleaner structure and improved documentation |
| src/index.ts | Updated main entry point to export both imperative API and hooks |
| example/App.tsx | Converted example app to use new hooks API |
| docs/HOOKS.md | Comprehensive documentation for the hooks API |
| package.json | Added React Compiler plugin |
| babel.config.js | Enabled React Compiler plugin |
| *.yml | Migrated CI from Bun to Yarn |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.