tamagui: Warning: Cannot update a component (`Button`) while rendering a different component (`Button`).
Current Behavior
Warning: Cannot update a component (`Button`) while rendering a different component (`Button`). To locate the bad setState() call inside `Button`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
In ios simulator using takeout.
Can confirm it’s tamagui because i haven’t updated my project to takeouts latest changes.
Same warning also shows in latest version of takeout as well.
Expected Behavior
No warning.
Tamagui Version
1.76.0
Platform (Web, iOS, Android)
ios, native, have not tried android yet
Reproduction
run the project
System Info
System:
OS: macOS 14.0
CPU: (12) arm64 Apple M2 Max
Memory: 79.66 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.asdf/installs/nodejs/18.16.0/bin/node
Yarn: 3.6.3 - /opt/homebrew/bin/yarn
npm: 9.5.1 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 8.9.2 - ~/Library/pnpm/pnpm
Browsers:
Chrome: 118.0.5993.117
Safari: 17.0
npmPackages:
@babel/runtime: ^7.18.9 => 7.22.15
@manypkg/cli: ^0.19.1 => 0.19.2
@nderscore/tamagui-typescript-plugin: ^0.5.1 => 0.5.4
@tamagui/cli: ^1.76.0 => 1.76.0
@turbo/gen: ^1.10.12 => 1.10.14
change-case: ^4.1.2 => 4.1.2
check-dependency-version-consistency: ^3.0.3 => 3.3.0
dotenv: ^16.3.1 => 16.3.1
dotenv-cli: ^6.0.0 => 6.0.0
eslint: ^8.46.0 => 8.49.0
node-gyp: ^9.3.1 => 9.4.0
prettier: ^2.7.1 => 2.8.8
ts-pattern: ^5.0.5 => 5.0.5
turbo: latest => 1.10.14
typescript: ^5.1.3 => 5.2.2
zx: ^7.2.3 => 7.2.3
About this issue
- Original URL
- State: open
- Created 8 months ago
- Reactions: 27
- Comments: 27 (4 by maintainers)
Commits related to this issue
- ignore annoying warning cf https://github.com/tamagui/tamagui/issues/1828 — committed to zk-passport/proof-of-passport by 0xturboblitz 5 months ago
- ignore annoying warning cf https://github.com/tamagui/tamagui/issues/1828 — committed to zk-passport/proof-of-passport by 0xturboblitz 5 months ago
I will get to this soon, but just know nothing is breaking. There’s a patch to get rid of it but it slows down your app theme changes a lot, I’d rather fix it right but it’s one of the most complex areas in Tamagui so needs a whole day or two of heavy concentration.
Yes, when I fixed the regression causing super slow theme changes these came back (the back and forth of fixing bugs 😕).
For some reason web is super fast and doesn’t mind queueMicrotask but native does. I think there’s some flag in Hermes you have to enable to make microtasks work like they should or something.
Anyway the error isn’t harmful just annoying. I will fix it soon.
Thanks guys I hear you. And sorry it’s taking so long.
I have my PR here with the refactor to fix it you can subscribe to.
I spent a few days on it in January and got a long way there but the long tail of getting the themes system correct + fast on every platform is quite long. In fact it’s pretty damn fast now so it’s been hard to match even without correctness. I’ll resume on it soon.
@natew Has this issue been fixed yet? I am getting it as well on web when using Select.
I’m getting a similar warning with the Tabs component.
Cannot update a component (H2) while rendering a different component (TabsTrigger). To locate the bad setState() call inside TabsTrigger, ...Changing the theme in 1.94.4 (using expo, native only) >>>
I’m getting these warning since I started using tamagui [v1.91.1]
Warning: Cannot update a component (Image) while rendering a different component (Card). To locate the bad setState() call insideCard, follow the stack trace as described in https://react.dev/link/setstate-in-renderWarning: Cannot update a component (Button) while rendering a different component (Button). To locate the bad setState() call insideButton, follow the stack trace as described in https://react.dev/link/setstate-in-renderWarning: Cannot update a component (Label) while rendering a different component (Fieldset). To locate the bad setState() call insideFieldset, follow the stack trace as described in https://react.dev/link/setstate-in-renderI get more of the warnings at a time, its really annoying 😒
And now I expericenced this:
At times it gets stuck in between, and sometimes the text color does not change at all or is some unusual gray.
@natew, done a great job, but the issue needs to be fixed at earnest.
Im having the same issue above when using Select component in ios and web.
Hi there,
Just more context: It is happening on 1.74.10 as well. When I remove the
<Theme>wrapper, it doesn’t show these warnings. @natew, which version were you referring to that this issue started from; I just wanted to let you know.I’m having this issue as well. I’ve been trying to figure out it but couldn’t find anything helpful yet.
The first thing that I noticed is that; my button element was like that
After I removed
themeInverseit (which is annoying), it started working ok.I am not sure why that argument for Button component was making a trouble.
I hope this will be fixed soon.
I’m getting a similar issue with the ToggleGroup component(latest version 1.94.5):
The same problem and it resolved by upgrading to 1.94.4
Hey Nate good work on everything, I know you’ve been busy but have you found any time to check this? It is really annoying for developing and debugging as you said. Thanks a lot.
A short-term fix is just to ignore the log since this is a non-destructive according to @natew.
I’m getting a similar issue with the Checkbox component:
ERROR Warning: Cannot update a component (
ForwardRef) while rendering a different component (Theme). To locate the bad setState() call insideTheme, follow the sta ck trace as described in https://react.dev/link/setstate-in-renderin Theme (created by Themed(Anonymous)) in Themed(Anonymous) (at checkbox-with-label.tsx:9) in RCTView (created by Checkbox) in Provider (created by Checkbox) in Checkbox
in Provider
in Unknown (created by Themed(Anonymous)) in Theme (created by Themed(Anonymous)) in Themed(Anonymous) (at checkbox-with-label.tsx:8) in RCTView (created by XStack) in XStack (at checkbox-with-label.tsx:7) in CheckboxWithLabel (at login.tsx:70) in RCTView
in Unknown (at login.tsx:69) in RCTView
in Unknown (at login.tsx:68) in Unknown (at login.tsx:64) in RCTView (created by Form) in Form
in FormProvider
in Unknown (at login.tsx:42) in RCTView (at View.js:116) in View (at ScrollView.js:1732) in RCTScrollView (at ScrollView.js:1855) in ScrollView (at ScrollView.js:1925) in ScrollView (created by ScrollView) in ScrollView (at login.tsx:41) in RNCSafeAreaView (at SafeAreaView.tsx:49) in Unknown (at login.tsx:39) in Login (at useScreens.js:112) in Unknown (at useScreens.js:116) in Suspense (at useScreens.js:115) in Route (at useScreens.js:131)
I have the same problem as @osmanyz with the latest version (^1.78.0)
Both the
themeInverseand thethemeproperties of the Button component cause the same errorI’m having the same issue on react-native when switching the theme with
<Theme name={theme}>...</Theme>Sometimes it’s crashing my app, I’m having 6 warnings of the same message with different components clashing, here for Circle: