You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v6.3.* causing crashes on react-native-web - nanoid is not a function #5705
Using styled-components 6.3* with react-native-web results in a silent warning during development and prevents the component from being styled correctly.
The issue originates from the postcss parse function, which is called within the generateStyleObject.
InlineStyle.ts:53 [styled-components/native] Failed to parse CSS: nanoid is not a function
n.generateStyleObject @ InlineStyle.ts:53
(anonymous) @ StyledNativeComponent.ts:76
E @ StyledNativeComponent.ts:117
react_stack_bottom_frame @ react-dom-client.development.js:25904
renderWithHooks @ react-dom-client.development.js:7662
updateForwardRef @ react-dom-client.development.js:9724
beginWork @ react-dom-client.development.js:12117
runWithFiberInDEV @ react-dom-client.development.js:871
performUnitOfWork @ react-dom-client.development.js:17641
workLoopSync @ react-dom-client.development.js:17469
renderRootSync @ react-dom-client.development.js:17450
performWorkOnRoot @ react-dom-client.development.js:16504
performWorkOnRootViaSchedulerTask @ react-dom-client.development.js:18957
performWorkUntilDeadline @ scheduler.development.js:45
<Styled(View)>
Expected Behaviour
Styled component applies the style.
Actual Behaviour
The component is unstyled, and a development console warning reports that nanoid is not a function.
changed the title [-]v6.* causing crashes on react-native-web[/-][+]v6.* causing crashes on react-native-web - nanoid is not a function[/+]on Mar 27, 2026
changed the title [-]v6.* causing crashes on react-native-web - nanoid is not a function[/-][+]v6.3.* causing crashes on react-native-web - nanoid is not a function[/+]on Mar 27, 2026
Thanks for the report and the repro repo, @marcobeltempo! This was a great catch.
The root cause is that postcss unconditionally requires nanoid/non-secure at module load time, and Metro/Expo can't resolve it in react-native-web contexts — so the entire styled-components import fails before any CSS is even parsed.
We've replaced postcss with a lightweight purpose-built CSS declaration parser for the React Native path. It's actually 2-3x faster than postcss for typical RN style declarations and handles all the edge cases (quoted strings, nested functions like calc()/var()/rgb(), data URIs, comments, etc.). This also removes postcss (along with nanoid and source-map-js) as a production dependency entirely.
Fix is on main and will be included in the final 6.4.0 release, but is not in the current RC/prerelease builds. Will follow up here once it's published so you can verify.
Thanks for the report and the repro repo, @marcobeltempo! This was a great catch.
The root cause is that postcss unconditionally requires nanoid/non-secure at module load time, and Metro/Expo can't resolve it in react-native-web contexts — so the entire styled-components import fails before any CSS is even parsed.
We've replaced postcss with a lightweight purpose-built CSS declaration parser for the React Native path. It's actually 2-3x faster than postcss for typical RN style declarations and handles all the edge cases (quoted strings, nested functions like calc()/var()/rgb(), data URIs, comments, etc.). This also removes postcss (along with nanoid and source-map-js) as a production dependency entirely.
Fix is on main and will be included in the final 6.4.0 release, but is not in the current RC/prerelease builds. Will follow up here once it's published so you can verify.
@quantizor Thank you for jumping on this so quickly!
Glad the fix is in, and it’s great to hear you got a performance win out of it too. We pulled [email protected]and haven't had any issues so far.
Activity
[-]v6.* causing crashes on react-native-web[/-][+]v6.* causing crashes on react-native-web - nanoid is not a function[/+][-]v6.* causing crashes on react-native-web - nanoid is not a function[/-][+]v6.3.* causing crashes on react-native-web - nanoid is not a function[/+]quantizor commentedon Mar 27, 2026
Thanks for the report and the repro repo, @marcobeltempo! This was a great catch.
The root cause is that
postcssunconditionally requiresnanoid/non-secureat module load time, and Metro/Expo can't resolve it in react-native-web contexts — so the entire styled-components import fails before any CSS is even parsed.We've replaced
postcsswith a lightweight purpose-built CSS declaration parser for the React Native path. It's actually 2-3x faster than postcss for typical RN style declarations and handles all the edge cases (quoted strings, nested functions likecalc()/var()/rgb(), data URIs, comments, etc.). This also removespostcss(along withnanoidandsource-map-js) as a production dependency entirely.Fix is on
mainand will be included in the final 6.4.0 release, but is not in the current RC/prerelease builds. Will follow up here once it's published so you can verify.fix(native): replace postcss, modernize RN path (#5705)
fix(native): replace postcss, optimize render path (#5705)
bench(native): add native benchmarks and RNW integration
fix(native): replace postcss, optimize render path (#5705)
quantizor commentedon Mar 28, 2026
Please try
[email protected]when you get a moment, should fix the issue and be faster as well.fix(native): replace postcss, optimize render path (#5705)
mrossmaple commentedon Mar 30, 2026
@quantizor @marcobeltempo I can confirm the issue is resolved on web with
6.4.0-prerelease.8!marcobeltempo commentedon Mar 30, 2026
@quantizor Thank you for jumping on this so quickly!
Glad the fix is in, and it’s great to hear you got a performance win out of it too. We pulled
[email protected]and haven't had any issues so far.Thanks again!