Skip to content

Conversation

@jakedahn
Copy link
Contributor

I'm running out of steam, but was hoping to get this fixed before I left for the day. After working through this with o3-mini, I think this might be a reasonable fix.

In the breaking commit, the removal of the useEffect (and the associated state/references) in CharmManagerContext.tsx meant that a new instance of the CharmManager was being created on every render rather than only when the effectiveReplica changed.

By wrapping the creation of the CharmManager in a useMemo that depends on effectiveReplica, the code ensures that the same instance is used across renders unless the effective replica actually changes.

@anotherjesse
Copy link
Contributor

@bfollington if this works for you feel free to merge!

@bfollington
Copy link
Contributor

Looks like the right fix to me, it's always dangerous storing reference types within useState

@bfollington bfollington merged commit 7f5c63b into main Feb 14, 2025
4 checks passed
@bfollington bfollington deleted the issue-380 branch February 14, 2025 03:25
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.

4 participants