Skip to content

fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184

Merged
mfazekas merged 2 commits intomainfrom
feat/hooks-undefined-initial-value
Mar 30, 2026
Merged

fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184
mfazekas merged 2 commits intomainfrom
feat/hooks-undefined-initial-value

Conversation

@mfazekas
Copy link
Copy Markdown
Collaborator

@mfazekas mfazekas commented Mar 19, 2026

Breaking changes to improve state transparency and prepare for the async experimental runtime.

useRiveFile error is now Error instead of string, and riveFile is undefined while loading (was null). isLoading is kept for convenience. Migration: {error} in JSX → {error.message}, and if checking riveFile type, null now means error not loading.

useViewModelInstance returns { instance, error } discriminated union instead of ViewModelInstance | null. Now accepts undefined source so you can pass useRiveFile().riveFile directly:

  • { 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 failed

required: true throws on null but not undefined (loading). Migration: const vmi = useViewModelInstance(file)const { instance, error } = useViewModelInstance(file).

useRiveNumber/String/Boolean/Color/Enum hooks start as undefined instead of reading property.value synchronously. The real value arrives via the listener's first emission.

@mfazekas mfazekas changed the base branch from feat/async-api-compat to main March 19, 2026 12:51
@mfazekas mfazekas force-pushed the feat/hooks-undefined-initial-value branch 2 times, most recently from e788362 to 8b84f79 Compare March 25, 2026 13:09
@mfazekas mfazekas changed the base branch from main to feat/async-api-compat March 25, 2026 13:09
Base automatically changed from feat/async-api-compat to main March 25, 2026 13:52
@mfazekas mfazekas force-pushed the feat/hooks-undefined-initial-value branch 2 times, most recently from 884bd40 to c987634 Compare March 26, 2026 07:45
@mfazekas mfazekas changed the title fix: useRive* hooks start undefined, value delivered via listener fix!: useRive* hooks start undefined, value delivered via listener Mar 26, 2026
@mfazekas mfazekas changed the title fix!: useRive* hooks start undefined, value delivered via listener fix!: useRive* hooks start undefined; useViewModelInstance exposes error state Mar 26, 2026
@mfazekas mfazekas changed the title fix!: useRive* hooks start undefined; useViewModelInstance exposes error state fix!: useRive* hooks start undefined; useViewModelInstance returns {instance,error} Mar 26, 2026
@mfazekas mfazekas force-pushed the feat/hooks-undefined-initial-value branch 2 times, most recently from b54c52c to 5a9c651 Compare March 27, 2026 14:47
@mfazekas mfazekas changed the title fix!: useRive* hooks start undefined; useViewModelInstance returns {instance,error} fix!: hooks start undefined, useViewModelInstance returns {instance, error} Mar 27, 2026
@mfazekas mfazekas force-pushed the feat/hooks-undefined-initial-value branch 2 times, most recently from e57ff6a to f71f8b4 Compare March 27, 2026 15:35
@mfazekas mfazekas marked this pull request as ready for review March 30, 2026 13:37
@mfazekas mfazekas requested a review from HayesGordon March 30, 2026 13:37
…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.
@mfazekas mfazekas force-pushed the feat/hooks-undefined-initial-value branch from 164180e to 7116ac7 Compare March 30, 2026 18:17
@mfazekas mfazekas enabled auto-merge (squash) March 30, 2026 18:17
@mfazekas mfazekas merged commit 059e5f4 into main Mar 30, 2026
9 checks passed
@mfazekas mfazekas deleted the feat/hooks-undefined-initial-value branch March 30, 2026 18:20
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants