Skip to content
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

Solidjs VList reactivity not working #425

Closed
imascha opened this issue Apr 2, 2024 · 3 comments · Fixed by #427
Closed

Solidjs VList reactivity not working #425

imascha opened this issue Apr 2, 2024 · 3 comments · Fixed by #427
Labels
help wanted Extra attention is needed

Comments

@imascha
Copy link
Contributor

imascha commented Apr 2, 2024

Describe the bug
As a minimal reproducable example, i created a VList with some example data and an Button that updates the example data.
But the DOM Elements don't update when the data is accessed trough the VList item, they only update when they are accessed trough the index. Is this wanted behaviour?

Example:

function App() {
  const [data, setData] = createSignal(["a", "b", "c", "d"]);
  return (
    <>
      <button onClick={() => setData(data().map((item) => item + item))}>
        Update data
      </button>
      <VList data={data()} style={{ height: "800px" }}>
        {(item, i) => (
          <div>
            {item} {data()[i]}
          </div>
        )}
      </VList>
    </>
  );
}

In this example only the {data()[i]} updates, when i click the button, the {item} never updates

To Reproduce
Here is a CodeSanbox of the Example: link

Expected behavior
Both the {data()[i]} and {item} should update, when i click the button

Platform:

  • OS: Windows
  • Browser: Chrome
  • Version of this package: 0.29.1
  • Version of framework: solid-js 1.8.14
@inokawa inokawa added the help wanted Extra attention is needed label Apr 3, 2024
@inokawa
Copy link
Owner

inokawa commented Apr 3, 2024

Hi, thank you for the reproduction.
Probably this is a bug. Perhaps we have to change the children API to have signal like (item, i) => <div>{item()} {i()}</div>.

I'll check this problem later, but it may take some time because I'm not a experienced Solid.js developer.
Any PR or contribution is welcome.

@imascha
Copy link
Contributor Author

imascha commented Apr 3, 2024

I was expecting it to work similar to the For primative from solid. There the item is not a function. I don't know if that is going to be difficult to implement. I'll check out if it is something i can fix.

@inokawa
Copy link
Owner

inokawa commented Apr 4, 2024

Released in 0.29.2. Thank you for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants