Skip to content

Fix text update recomputing in @preact/signals 1.3.x #617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/preact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ function SignalValue(this: AugmentedComponent, { data }: { data: Signal }) {
}

this._updater!._callback = () => {
// When overriding Effect._callback, source versions are only updated between _start() and end(), not when the callback is executed.
// To fix this, whenever _callback is executed we update the Effect's source versions to their latest values.
// Note that we don't do this for the re-rendering Component updater, because that eventually calls _start().
for (let source = this._updater!._sources; source !== undefined; source = source._nextSource) {
source._version = source._source._version;
}

if (isValidElement(s.peek()) || this.base?.nodeType !== 3) {
this._updateFlags |= HAS_PENDING_UPDATE;
this.setState({});
Expand Down