preactjs / preactjs/preact

Preact toChildArray does not assign keys

Open
#2,888 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

compat
Dominant language
JavaScript
Stars
38.9k
Forks
2.4k
Avg merge
20h 18m
Merged PRs (30d)
35

Description

Reproduction

https://fanatical-dot-bumper.glitch.me/

In React documentation, they say

That is, toArray prefixes each key in the returned array so that each element’s key is scoped to the input array containing it.

In other words, it will assign keys, even if they were undefined before. This is not the case for Preact's implementation and causes issues when using preact/compat

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Glitch reproduction and trace Preact's toChildArray behavior, especially through preact/compat. Compare the returned elements with the React documentation's stated key behavior; done means previously undefined keys are assigned consistently and the reported compatibility issue no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.