fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184
Merged
fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184
Conversation
e788362 to
8b84f79
Compare
884bd40 to
c987634
Compare
b54c52c to
5a9c651
Compare
e57ff6a to
f71f8b4
Compare
HayesGordon
approved these changes
Mar 30, 2026
…error} useRiveNumber/String/Boolean/Color/Enum hooks start as undefined — the real value arrives via listener. useViewModelInstance returns a discriminated union: undefined (loading), null (resolved empty/error), or ViewModelInstance (success).
Align useRiveFile with useViewModelInstance semantics: riveFile is undefined while loading (was null), error is Error object (was string). isLoading kept for convenience. Memoize error in useViewModelInstance, accept undefined source to avoid ?? null at call sites.
164180e to
7116ac7
Compare
mfazekas
pushed a commit
that referenced
this pull request
Mar 31, 2026
🤖 I have created a release *beep* *boop* --- ## [0.4.0](v0.3.4...v0.4.0) (2026-03-30) ### ⚠ BREAKING CHANGES * hooks start undefined, useViewModelInstance returns {instance, error} ([#184](#184)) ### Bug Fixes * hooks start undefined, useViewModelInstance returns {instance, error} ([#184](#184)) ([059e5f4](059e5f4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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.
Breaking changes to improve state transparency and prepare for the async experimental runtime.
useRiveFileerror is nowErrorinstead ofstring, andriveFileisundefinedwhile loading (wasnull).isLoadingis kept for convenience. Migration:{error}in JSX →{error.message}, and if checkingriveFiletype,nullnow means error not loading.useViewModelInstancereturns{ instance, error }discriminated union instead ofViewModelInstance | null. Now acceptsundefinedsource so you can passuseRiveFile().riveFiledirectly:{ instance: undefined, error: null }— loading (source not ready){ instance: ViewModelInstance, error: null }— success{ instance: null, error: null }— resolved, no ViewModel{ instance: null, error: Error }— lookup failedrequired: truethrows onnullbut notundefined(loading). Migration:const vmi = useViewModelInstance(file)→const { instance, error } = useViewModelInstance(file).useRiveNumber/String/Boolean/Color/Enumhooks start asundefinedinstead of readingproperty.valuesynchronously. The real value arrives via the listener's first emission.