Before submitting a new issue
Bug summary
styled() can cause TypeScript to hang when wrapping components whose props include complex ref types, such as react-strict-dom elements.
Minimal example:
import { html } from "react-strict-dom";
import { styled } from "react-native-css";
export const StyledDiv = styled(html.div, { className: "style" });
export const element = <StyledDiv className="p-4" />;
What I found
The issue appears to come from StyledConfiguration computing dot-notation style targets from:
DotNotation<ComponentProps<C>>
For html.div, ComponentProps<C> includes:
ref?: React.Ref<HTMLDivElement>
DotNotation then recursively walks into the ref type, then into HTMLDivElement, which expands into a large recursive DOM type graph.
I verified locally that:
ComponentProps<typeof html.div> typechecks quickly.
DotNotation<Pick<Props, "style">> typechecks quickly.
DotNotation<Pick<Props, "ref">> hangs.
styled(html.div, { className: "style" }) hangs before the fix.
Library version
3.0.7
Environment info
Node: 24.13.0
TypeScript: 5.9.2
react-native-css: 3.0.7
react-strict-dom: 0.0.55
react: 19.1.0
react-native: 0.81.4
Steps to reproduce
- Clone the repro repository.
- Install dependencies.
- Run
npm run typecheck.
Reproducible example repository
https://github.com/emmanuelchucks/react-native-css-styled-rsd-ref-repro
Possible fix
Using PropsWithoutRef<ComponentProps<C>> for style-mapping target inference avoids walking ref, while still preserving ref on the returned styled component props.
Conceptually:
DotNotation<PropsWithoutRef<ComponentProps<C>>>
instead of:
DotNotation<ComponentProps<C>>
Before submitting a new issue
Bug summary
styled()can cause TypeScript to hang when wrapping components whose props include complexreftypes, such asreact-strict-domelements.Minimal example:
What I found
The issue appears to come from
StyledConfigurationcomputing dot-notation style targets from:For
html.div,ComponentProps<C>includes:DotNotationthen recursively walks into thereftype, then intoHTMLDivElement, which expands into a large recursive DOM type graph.I verified locally that:
ComponentProps<typeof html.div>typechecks quickly.DotNotation<Pick<Props, "style">>typechecks quickly.DotNotation<Pick<Props, "ref">>hangs.styled(html.div, { className: "style" })hangs before the fix.Library version
3.0.7
Environment info
Steps to reproduce
npm run typecheck.Reproducible example repository
https://github.com/emmanuelchucks/react-native-css-styled-rsd-ref-repro
Possible fix
Using
PropsWithoutRef<ComponentProps<C>>for style-mapping target inference avoids walkingref, while still preservingrefon the returned styled component props.Conceptually:
instead of: