Skip to content

2.0.0-beta.2 onCleanup never runs from inside of ref callback #2624

@kanashimia

Description

@kanashimia

Describe the bug

export default function App() {
  const [toggle, setToggle] = createSignal(0);
  return (
    <div>
      <Show when={toggle()}>
        <div ref={(el) => {
          console.log("start")
          onCleanup(() => {
            console.log("end")
          })
        }}>TEXT</div>
      </Show>
      <button onClick={() => setToggle(v => v ^ 1)}>
        Toggle: {toggle()}
      </button>
    </div>
  );
}

Your Example Website or App

https://solid2.netlify.app/#solidjs-repl:hyRmJjyHRvuhjuBJaIyBBA

Steps to Reproduce the Bug or Issue

When you click a button in the reproducer you should only see "start" but no "end"
If you switch to the 1.9 version there it will all be ok

Expected behavior

.

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

zulu writes on discord:

in the ref
there is no owner in 2.x playground

but there is in 1.x playground

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