Skip to content

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

Draft
mfazekas wants to merge 1 commit intomainfrom
feat/hooks-undefined-initial-value
Draft

fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184
mfazekas wants to merge 1 commit 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.

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. Consumers must guard: if (value === undefined) return <Loading />;

useViewModelInstance returns { instance, error } discriminated union instead of ViewModelInstance | null:

  • { 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 (resolved error) but not undefined (loading). Migration: const vmi = useViewModelInstance(file)const { instance, error } = useViewModelInstance(file). See #194 for why the error case matters.

@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 from 5a9c651 to e57ff6a Compare March 27, 2026 15:26
…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).
@mfazekas mfazekas force-pushed the feat/hooks-undefined-initial-value branch from e57ff6a to f71f8b4 Compare March 27, 2026 15:35
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.

1 participant