Skip to content

Conversation

@webstrand
Copy link
Contributor

Fixes #785

This substantially rewrites repeat to be more straight-forward with fewer closures, unlike #786 which is more conservative.

@changeset-bot
Copy link

changeset-bot bot commented Apr 20, 2025

🦋 Changeset detected

Latest commit: 0192f34

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solid-primitives/range Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@webstrand
Copy link
Contributor Author

This is actually kind of broken still, if the array returned from repeat()() is mutated, internal state can be corrupted

@thetarnav
Copy link
Member

That’s fine
The same probably happens with mapArray and others
When mutating the result one should copy
Nothing broken with that

@webstrand
Copy link
Contributor Author

Is it appropriate to narrow the return type to readonly T[] then to signal to users not to mutate the return value?

I've narrowed the return type in the most recent batch of commits, and I've fixed a bug in my implementation and added another test.

I'm not sure if you'd rather have a single commit in the PR or multiple?

@thetarnav
Copy link
Member

readonly arrays are not allowed by JSX types, so I wouldn't do that.

@webstrand
Copy link
Contributor Author

webstrand commented Apr 24, 2025

Ah is it intended then that repeat() be typed for being passed into JSX directly? The <Repeat> wrapper doesn't have any trouble with it, since it casts to JSX.Element directly ignoring the readonly annotation.

@thetarnav thetarnav merged commit df736b6 into solidjs-community:main Apr 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<Repeat/> does not update when its times.prop changes

2 participants