feat: onError property for RiveView#25
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces an onError callback property to the RiveView component, allowing consumers to handle errors that occur during Rive animation rendering and configuration. The implementation includes a default error handler that logs to console.error and provides a structured RiveError type with both a message and an error type enum for categorization.
Key changes:
- Added
RiveErrorinterface andRiveErrorTypeenum for structured error handling - Introduced
onErrorcallback prop onRiveViewwith a default console.error handler - Replaced native logging in error handlers with callback invocation on both iOS and Android platforms
Reviewed Changes
Copilot reviewed 9 out of 37 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
src/specs/RiveView.nitro.ts |
Added onError property to native interface specification |
src/index.tsx |
Refactored to wrap native component and expose new RiveViewRef type |
src/core/RiveView.tsx |
Created wrapper component with default error handler and updated documentation |
src/core/Errors.ts |
Defined RiveError interface and RiveErrorType enum with 8 error categories |
src/hooks/useRive.ts |
Updated to use new RiveViewRef type for improved type safety |
nitrogen/generated/* |
Auto-generated bindings for C++, Swift, and Kotlin platforms |
ios/HybridRiveView.swift |
Implemented error detection and callback invocation for iOS |
ios/RiveReactNativeView.swift |
Updated configuration methods to throw errors instead of silently failing |
ios/Utils.swift |
Removed generic logged utility function (moved to component-specific implementation) |
android/src/main/java/com/margelo/nitro/rive/HybridRiveView.kt |
Implemented error detection and callback invocation for Android |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 11 out of 39 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix import cycle by extracting NitroRiveView to separate file - Make error types human-readable in logs (show enum names instead of numbers) - Improve iOS error detection using RiveErrorCode enum values instead of string comparisons - Rename NativeRiveError to NitroRiveError for consistency with Nitro Modules naming - Make detectErrorType return tuple with both error type and message - Add NitroRiveError.fileNotFound case for asset loading errors - Remove non-existent error types (TextRunNotFoundError, IncorrectAnimationName) - Map instanceNotFound errors to DataBindingError type 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add IncorrectAnimationName and IncorrectStateMachineInputName error types - Fix iOS to map noStateMachineInputFound to IncorrectStateMachineInputName instead of IncorrectAnimationName - Fix Android to use correct error types instead of UNKNOWN - Regenerate Nitrogen bindings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Rename DataBindingError to ViewModelInstanceNotFound - Remove IncorrectAnimationName (map to Unknown) - Remove TextRunNotFoundError (map to Unknown) - Make Android detectErrorType return Pair<RiveErrorType, String> for consistency with iOS - Update both platforms to use cleaner error messages - Regenerate Nitrogen bindings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
c120a49 to
3791d51
Compare
Introduce
onError()callback onRiveView. This is a required fn and defaults toconsole.error