fix: stabilize lifecycle and Elixir 1.20 compatibility - #55
Open
geonwoo-jeong wants to merge 3 commits into
Open
fix: stabilize lifecycle and Elixir 1.20 compatibility#55geonwoo-jeong wants to merge 3 commits into
geonwoo-jeong wants to merge 3 commits into
Conversation
geonwoo-jeong
force-pushed
the
fix/jeo-86-production
branch
from
August 14, 2026 13:17
bcbf18f to
e1afb48
Compare
geonwoo-jeong
marked this pull request as ready for review
August 14, 2026 13:29
geonwoo-jeong
marked this pull request as draft
August 14, 2026 13:39
geonwoo-jeong
marked this pull request as ready for review
August 14, 2026 13:40
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.
Contributor checklist
Summary
This draft builds on #54 and adds a small set of production hardening changes without altering its props-diff or streams design:
LiveReact.Encoder.encode/1andencode/2while removing deprecated protocol default arguments on Elixir 1.20Why these changes are needed
React root lifecycle
The previous
destroyed()callback deferred unmounting untilphx:page-loading-stop. That event is tied to page navigation and is not guaranteed when a LiveView patch only removes the component, so the React root and its effects could remain alive after the hook had been destroyed. The deferred callback also read the mutablethis._rootlater, which could target a different root if the hook state changed in the meantime.The hook now captures the current root, clears
this._root, and unmounts immediately. Clearing the reference before unmounting makes repeated or re-entrantdestroyed()calls safe and guarantees that the same root is unmounted exactly once.Protocol callback compatibility
The encoder previously declared
def encode(value, opts \\ [])insidedefprotocol. Elixir 1.20 deprecates default arguments in protocol definitions and warns that protocols may only declare callbacks without an implementation. These warnings fail projects that compile dependencies with warnings treated as errors.The protocol now declares
encode/1andencode/2explicitly. Each implementation definesencode(value)as a direct delegation toencode(value, []), preserving the existing one-argument API and behavior while making both protocol arities explicit and compatible with Elixir 1.20.Validation
phx:page-loading-stopand a repeateddestroyed()callencode(value)toencode(value, [])behavior across its protocol implementationsphoenix_ectoboundary without requiring external provider or network callsFollow-up to #54.