fix: make useRiveProperty setValue a no-op before instance is ready#155
Merged
fix: make useRiveProperty setValue a no-op before instance is ready#155
Conversation
7622ffc to
9bafbe1
Compare
9bafbe1 to
4a5af1b
Compare
HayesGordon
reviewed
Feb 24, 2026
| `Cannot set value for property "${path}" because it was not found. Your view model instance may be undefined, or the path may be incorrect.` | ||
| ) | ||
| ); | ||
| return; |
Contributor
There was a problem hiding this comment.
What about the scenario where the property is in fact invalid?
Collaborator
Author
There was a problem hiding this comment.
What about the scenario where the property is in fact invalid?
There is an useEffect on line 63 covering that.
rive-nitro-react-native/src/hooks/useRiveProperty.ts
Lines 63 to 69 in 4a5af1b
And I've added a test case covering this:
rive-nitro-react-native/src/hooks/__tests__/useRiveProperty.test.ts
Lines 86 to 98 in 4a5af1b
…141) setValue was throwing an error when called before the ViewModelInstance loaded. This is a common React pattern — useEffect fires on mount before async data is available. Changed to silent no-op matching react-hook-form and React 18 conventions. React's dependency array re-fires the effect when setValue identity changes after instance loads. Adds Jest unit tests and harness test for the behavior.
4a5af1b to
a4177c6
Compare
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.
Fixes #141 (hooks level)
useRiveProperty'ssetValuewas throwing an error when called before theViewModelInstanceloaded. This is a common React pattern —useEffectfires on mount before async data is available.Changed to silent no-op, as setValue does changes once the instance is available, no internal queue needed — React's dependency array handles it:
Reproducer