Skip to content

Conversation

@necolas
Copy link

@necolas necolas commented Jan 23, 2026

Description / Motivation

Move setMounted(true) and rebuildTree() calls from the render phase into the useState initializer. This ensures these side effects run only once during initial tree creation rather than on every render.

The render phase should be pure with no side effects. Previously, these mutations were called on every render unnecessarily. @headless-tree/core handles rebuilds lazily via getItems() when rebuildScheduled is true, and setConfig() only triggers immediate rebuilds when expandedItems changes.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality). You must have
    first discussed with the dev team and they should be aware that this PR is
    being opened
  • Breaking change (fix or feature that would change existing functionality).
    You must have first discussed with the dev team and they should be aware
    that this PR is being opened
  • Documentation update

Checklist

  • I have read the
    contributing guidelines
  • My code follows the code style of the project (bun run lint)
  • My code is formatted properly (bun run format)
  • I have updated the documentation accordingly (if applicable)
  • I have added tests to cover my changes (if applicable)
  • All new and existing tests pass (bun run diffs:test)

@vercel
Copy link

vercel bot commented Jan 23, 2026

@necolas is attempting to deploy a commit to the Pierre Computer Company Team on Vercel.

A member of the Team first needs to authorize it.

Move setMounted(true) and rebuildTree() calls from the render phase
into the useState initializer. This ensures these side effects run
only once during initial tree creation rather than on every render.

The render phase should be pure with no side effects. Previously,
these mutations were called on every render unnecessarily.
@headless-tree/core handles rebuilds lazily via getItems() when
rebuildScheduled is true, and setConfig() only triggers immediate
rebuilds when expandedItems changes.
@necolas necolas force-pushed the file-tree/state-init branch from adaa657 to 7788b0d Compare January 23, 2026 22:19
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.

1 participant