Conversation
Property setter functions (setValue, setButtonText, etc.) from useRive* hooks were unstable because the options object was recreated on each render, even though useCallback was used for getProperty. This caused unnecessary re-renders and listener resets. Extract options to global constants to ensure stable object references across renders. For useRiveTrigger, use useMemo to recreate options only when onTrigger changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45b6fbc to
78b07be
Compare
78b07be to
2b7492b
Compare
HayesGordon
reviewed
Oct 28, 2025
| - name: Install cocoapods | ||
| if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true' | ||
| run: | | ||
| yarn nitrogen |
Contributor
There was a problem hiding this comment.
Can decide this later, but might prefer to commit the nitrogen generated code
Collaborator
Author
There was a problem hiding this comment.
👍 Yes let's do that, otherwise it's a pain with for example builder bob. Ideally we'd have a gh action that checks if the generated files are uptodate.
HayesGordon
approved these changes
Oct 28, 2025
Contributor
HayesGordon
left a comment
There was a problem hiding this comment.
LGTM! Congrats on the first PR
mfazekas
added a commit
that referenced
this pull request
Nov 17, 2025
…x ci (#1) * fix: stabilize property setter functions by using global options Property setter functions (setValue, setButtonText, etc.) from useRive* hooks were unstable because the options object was recreated on each render, even though useCallback was used for getProperty. This caused unnecessary re-renders and listener resets. Extract options to global constants to ensure stable object references across renders. For useRiveTrigger, use useMemo to recreate options only when onTrigger changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(chore): ci - fix --------- Co-authored-by: Claude <noreply@anthropic.com>
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.
Summary
This PR fixes the issue where property setter functions from
useRive*hooks were unstable, causing unnecessary re-renders.Changes
useRiveBoolean,useRiveNumber,useRiveString, anduseRiveColoruseMemoinuseRiveTriggerto recreate options only whenonTriggerchangesuseCallbackimports where no longer neededProblem
Property setter functions (setValue, setButtonText, etc.) were unstable because the options object passed to
useRivePropertywas recreated on each render, even thoughuseCallbackwas used for thegetPropertyfunction. This caused theuseMemoanduseEffectinuseRivePropertyto re-run unnecessarily, resetting listeners and creating instability.Solution
By extracting the options to global constants, we ensure stable object references across renders. For
useRiveTrigger, which has a dynamiconTriggerparameter, we useuseMemoto only recreate the options whenonTriggeractually changes.Test plan
To reproduce the issue: In example/src/pages/RiveDataBindingExample.tsx, apply this diff:
pressing the change button should change the button for good. Previously it was changed, but changed back immediately
🤖 Generated with Claude Code