`styled()` crashes with `Maximum call stack size exceeded` when wrapping `react-native-svg` primitives
Mantenedores costumam responder em até 3 dias
@marklawlor já está trabalhando nisso.
Desde 15/7/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Describe the bug
In [email protected], the documented v5 third-party-component recipe for react-native-svg throws on first render:
RangeError: Maximum call stack size exceeded (native stack depth)
The same crash also fires when calling useUnstableNativeVariable() from a component rendered inside an SVG tree — so the bug appears to live in the shared observable/effect layer that both APIs route through (useNativeCss → varResolver → reactivity graph), not in styled() itself.
Plain <Svg color={someStaticHex} /> with the color resolved outside of any NativeWind runtime hook renders correctly. Only the NativeWind runtime path crashes.
Versions:
nativewind:5.0.0-preview.4react-native-css:3.0.7react-native-svg:15.15.4react-native:0.85.3react:19.2.3expo:56.0.11(SDK 56)tailwindcss:4.2.0(Tailwind v4,@theme {}block)- Platform: iOS simulator, Hermes
Reproduction
npx rn-new@latest --nativewind then drop in:
import { styled } from 'nativewind';
import Svg, { Path } from 'react-native-svg';
const StyledSvg = styled(Svg);
const StyledPath = styled(Path);
export default function App() {
return (
<StyledSvg width={24} height={24} viewBox="0 0 24 24" className="text-red-500">
<StyledPath d="M2 12h20" stroke="currentColor" strokeWidth={2} />
</StyledSvg>
);
}
The documented nativeStyleMapping recipe reproduces the same crash:
const StyledSvg = styled(Svg, {
className: { target: 'style', nativeStyleMapping: { color: 'color' } },
});
Expected behavior
styled(Svg, { className: { target: 'style', nativeStyleMapping: { color: 'color' } } }) should resolve text-… classes to a color value and lift it onto the <Svg color={…}> prop, so stroke="currentColor" on descendants follows the Tailwind text color. This is the v4 cssInterop recipe that the v5 third-party-components guide still points to.
Additional context
Two suspect spots in [email protected] that fit the symptom (not confirmed by runtime instrumentation):
useNativeCssrunssetStateduring render iftestGuardsflips.react-native-svg'sSvg/Shapeclass components rebuild prop derivations on every render (extractedProps,SvgTouchableMixin,setNativeProps), so an identity-based guard may flip on every iteration and recurse synchronously.varResolver'svariableHistoryonly blocks repeating the same variable name — it doesn't catch cycles across different names. Tailwind v4 OKLCH palette colors compile to nestedvar()chains, which may be enough to trigger that.
Workaround in use: resolve the color from className ourselves via useColorScheme() + a static token map mirrored from our @theme {} block, then pass it as <Svg color={…} />. Inner Path/Circle stay as plain react-native-svg primitives with stroke="currentColor". Works, but duplicates values from CSS and can't read live runtime variables.
What I tried that did not help:
- Every
nativeStyleMappingshape onstyled(Svg, …). - Wrapping only the outer
<Svg>and leaving inner primitives untouched. - Calling
useUnstableNativeVariable('color-foreground-tertiary')before any SVG primitive renders — still crashes.
Related: #242 — [V5] - styled doesn't work as it worked in V4 — same symptom shape, marked Done in roadmap but not yet in a published preview.
- Linguagem predominante
- TypeScript
- Estrelas
- 166
- Forks
- 45
- Merge médio
- 13d 14h
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de nativewind/react-native-css
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nativewind/react-native-css#545 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nativewind/react-native-css#544 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nativewind/react-native-css#543 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
nativewind/react-native-css#540 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
nativewind/react-native-css#538 ·
Mantenedores costumam responder em até 3 dias
Todas as issues de nativewind/react-native-css
Issues semelhantes
-
b:minor bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
software-mansion/argent#1698 ·
Mantenedores costumam responder em até 1 dia
-
e2e-failure ready-to-code
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
redhat-developer/rhdh-plugin-export-overlays#4624 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
better-auth/better-auth#12132 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
automation missing-model model-sync provider:tinfoil
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
anomalyco/models.dev#12053 ·
Mantenedores costumam responder em até 1 dia
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
hurttlocker/o8#5112 ·