mui / mui/base-ui

[all components] Avoid using DOM to derive state

Open
#3,035 0 comments 1 reaction 0 assignees View on GitHub
scope: all components
Dominant language
TypeScript
Stars
10.9k
Forks
543
Avg merge
1d 20h
Merged PRs (30d)
101

Description

# Bug report

## Current behavior

In some components we depend on the DOM in order to derive some state, which causes the components to need to be rendered multiple times to get to the final state. Some example sinclude:
- https://github.com/mui/base-ui/blob/a4017b603c1709f4593502bc02b06130647f664b/packages/react/src/field/label/FieldLabel.tsx#L29-L36
- https://github.com/mui/base-ui/blob/a4017b603c1709f4593502bc02b06130647f664b/packages/react/src/radio/root/RadioRoot.tsx#L68-L72
- https://github.com/mui/base-ui/blob/a4017b603c1709f4593502bc02b06130647f664b/packages/react/src/tabs/tab/TabsTab.tsx#L101

In general we can search for `useIsoLayoutEffect` calls that update some state inside.

## Expected behavior

It would be great if we can have an alternative API to avoid this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.