Skip to content

2.0.0-beta.20: latest() only works once on memos #2922

Description

@AFatNiBBa

Describe the bug

If you cause a memo to mutate in between two usages of latest(), the second one will ignore the changes

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-eanyzwnd?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

  1. Navigate to the example link
  2. Press the "Test" button
  3. Look at the object that's being logged into the console

Expected behavior

When running

const v1 = m();       // 1
s(1);
const v2 = m();       // 1
const v3 = latest(m); // 3
const v4 = m();       // 1
s(2);
const v5 = m();       // 1
const v6 = latest(m); // 3 (This has not updated!)
flush();
const v7 = m();       // 5
console.log({ v1, v2, v3, v4, v5, v6, v7 });

I expected this to be logged

{
    "v1": 1,
    "v2": 1,
    "v3": 3,
    "v4": 1,
    "v5": 1,
    "v6": 5,
    "v7": 5
}

but I got this instead

{
    "v1": 1,
    "v2": 1,
    "v3": 3,
    "v4": 1,
    "v5": 1,
    "v6": 3, // Wrong!
    "v7": 5
}

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Edge (The Chromium one)
  • Version: 150.0.4078.65

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions