fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184
Draft
fix!: hooks start undefined, useViewModelInstance returns {instance, error}#184
Conversation
e788362 to
8b84f79
Compare
884bd40 to
c987634
Compare
b54c52c to
5a9c651
Compare
5a9c651 to
e57ff6a
Compare
…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).
e57ff6a to
f71f8b4
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.
Breaking changes to improve state transparency and prepare for the async experimental runtime.
useRiveNumber/String/Boolean/Color/Enumhooks start asundefinedinstead of readingproperty.valuesynchronously. The real value arrives via the listener's first emission. Consumers must guard:if (value === undefined) return <Loading />;useViewModelInstancereturns{ instance, error }discriminated union instead ofViewModelInstance | 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 failedrequired: truethrows onnull(resolved error) but notundefined(loading). Migration:const vmi = useViewModelInstance(file)→const { instance, error } = useViewModelInstance(file). See #194 for why the error case matters.