Skip to content

Conversation

@ParSal123
Copy link
Contributor

React's children api map function supports a "context" argument that we don't.
Fixes #2644.

Based mostly on #2645.

There was a problem though: When I ran npm run test:karma, it didn't test Children.test.js. Even the pipeline on the forked project didn't run Children.test.js. I couldn't figure it out. Don't know if this is an issue or just misconfiguration.

React's children api map function supports a "context" argument that we
don't.
See preactjs#2644.
@github-actions
Copy link

github-actions bot commented Aug 6, 2025

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-1.86ms - +4.98ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.14ms - +0.02ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +2% (-1.12ms - +1.16ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -3% - +0% (-0.43ms - +0.03ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +1% (-1.05ms - +0.77ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -4% - +5% (-0.07ms - +0.09ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.20ms - +0.38ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -4% - +2% (-1.39ms - +0.73ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +1% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -7% - +5% (-0.45ms - +0.33ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +0% (-0.03ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -4% - +5% (-0.04ms - +0.05ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local957.42ms - 962.73ms-unsure 🔍
-0% - +1%
-1.86ms - +4.98ms
preact-main956.35ms - 960.67msunsure 🔍
-1% - +0%
-4.98ms - +1.86ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.03ms - 19.03ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-main19.03ms - 19.04msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.47ms - 16.51ms-unsure 🔍
-1% - +0%
-0.14ms - +0.02ms
preact-main16.47ms - 16.63msunsure 🔍
-0% - +1%
-0.02ms - +0.14ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.52ms - 1.54ms-unsure 🔍
-0% - +1%
-0.01ms - +0.01ms
preact-main1.53ms - 1.53msunsure 🔍
-1% - +0%
-0.01ms - +0.01ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local66.63ms - 68.21ms-unsure 🔍
-2% - +2%
-1.12ms - +1.16ms
preact-main66.58ms - 68.22msunsure 🔍
-2% - +2%
-1.16ms - +1.12ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local5.94ms - 6.50ms-unsure 🔍
-7% - +5%
-0.45ms - +0.33ms
preact-main6.01ms - 6.55msunsure 🔍
-5% - +7%
-0.33ms - +0.45ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.09ms - 16.50ms-unsure 🔍
-3% - +0%
-0.43ms - +0.03ms
preact-main16.39ms - 16.59msunsure 🔍
-0% - +3%
-0.03ms - +0.43ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.71ms - 3.72ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.71ms - 3.72msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #4992
  • Commit: 4b35d10

duration

VersionAvg timevs preact-localvs preact-main
preact-local65.06ms - 66.16ms-unsure 🔍
-2% - +1%
-1.05ms - +0.77ms
preact-main65.03ms - 66.48msunsure 🔍
-1% - +2%
-0.77ms - +1.05ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.09ms - 3.12ms-unsure 🔍
-1% - +0%
-0.03ms - +0.01ms
preact-main3.10ms - 3.13msunsure 🔍
-0% - +1%
-0.01ms - +0.03ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.53ms - 26.29ms-unsure 🔍
-1% - +4%
-0.19ms - +0.89ms
preact-main25.18ms - 25.95msunsure 🔍
-3% - +1%
-0.89ms - +0.19ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local33.55ms - 34.63ms-unsure 🔍
-3% - +2%
-0.87ms - +0.66ms
preact-main33.65ms - 34.74msunsure 🔍
-2% - +3%
-0.66ms - +0.87ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local29.79ms - 30.76ms-unsure 🔍
-1% - +3%
-0.38ms - +0.93ms
preact-main29.56ms - 30.44msunsure 🔍
-3% - +1%
-0.93ms - +0.38ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local27.56ms - 28.42ms-unsure 🔍
-1% - +3%
-0.34ms - +0.87ms
preact-main27.29ms - 28.15msunsure 🔍
-3% - +1%
-0.87ms - +0.34ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local22.73ms - 23.89ms-unsure 🔍
-5% - +2%
-1.16ms - +0.50ms
preact-main23.04ms - 24.23msunsure 🔍
-2% - +5%
-0.50ms - +1.16ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local21.79ms - 22.52ms-unsure 🔍
-1% - +4%
-0.21ms - +0.83ms
preact-main21.47ms - 22.21msunsure 🔍
-4% - +1%
-0.83ms - +0.21ms
-
text-update

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.82ms - 1.94ms-unsure 🔍
-4% - +5%
-0.07ms - +0.09ms
preact-main1.82ms - 1.92msunsure 🔍
-5% - +4%
-0.09ms - +0.07ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local0.97ms - 1.03ms-unsure 🔍
-4% - +5%
-0.04ms - +0.05ms
preact-main0.97ms - 1.03msunsure 🔍
-5% - +4%
-0.05ms - +0.04ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.57ms - 34.10ms-unsure 🔍
-1% - +1%
-0.20ms - +0.38ms
preact-main33.63ms - 33.87msunsure 🔍
-1% - +1%
-0.38ms - +0.20ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.25ms - 1.25ms-unsure 🔍
-1% - +0%
-0.01ms - +0.00ms
preact-main1.24ms - 1.26msunsure 🔍
-0% - +1%
-0.00ms - +0.01ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local30.70ms - 31.93ms-unsure 🔍
-4% - +2%
-1.39ms - +0.73ms
preact-main30.78ms - 32.51msunsure 🔍
-2% - +4%
-0.73ms - +1.39ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.93ms - 2.93ms-unsure 🔍
-0% - +0%
-0.01ms - +0.00ms
preact-main2.93ms - 2.94msunsure 🔍
-0% - +0%
-0.00ms - +0.01ms
-

tachometer-reporter-action v2 for CI

@coveralls
Copy link

Coverage Status

coverage: 99.535%. remained the same
when pulling 4b35d10 on ParSal123:master
into ac657fc on preactjs:main.

Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this sat for so long but we appreciate it!

@rschristian rschristian merged commit 2c47637 into preactjs:main Aug 6, 2025
13 checks passed
@JoviDeCroock JoviDeCroock mentioned this pull request Aug 19, 2025
const mapFn = (children, fn, context) => {
if (children == null) return null;
return toChildArray(toChildArray(children).map(fn));
return toChildArray(toChildArray(children).map(fn.bind(context)));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to bind here no ?

toChildArray(toChildArray(children).map(fn, context))

Map accept the context as a secondary argument already

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.

Differences in Preact.Children API and React.Children API

5 participants