tamagui: Disabled button error with animation
Current Behavior
When button have animation, and we are disabling a button, it throws an error:
ERROR Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
Expected Behavior
Button should correctly apply disabled styles
Tamagui Version
1.116.12
Platform (Web, iOS, Android)
iOS, Android
I don’t know about web
Reproduction
1. Create new StyledButton component:
import { Button, styled } from "tamagui";
const StyledButton = styled(Button, {
animation: "quick",
});
2. Use this button and change it to disable
export default function IndexScreen() {
const [isDisabled, setIsDisabled] = useState(false);
return (
<>
<Button onPress={() => setIsDisabled(!isDisabled)}>
{isDisabled ? "Enable" : "Disable"}
</Button>
<StyledButton disabled={isDisabled}>
State: {isDisabled ? "Disabled" : "Enabled"}
</StyledButton>
</>
);
System Info
System:
OS: macOS 15.1
CPU: (10) arm64 Apple M2 Pro
Memory: 896.67 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.18.0/bin/yarn
npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
Browsers:
Chrome: 130.0.6723.116
Safari: 18.1
npmPackages:
@apollo/client: ^3.11.8 => 3.11.8
@babel/core: ^7.20.0 => 7.25.9
@expo/vector-icons: ^14.0.2 => 14.0.4
@graphql-codegen/cli: ^5.0.3 => 5.0.3
@graphql-codegen/graphql-modules-preset: ^4.0.10 => 4.0.10
@graphql-codegen/introspection: ^4.0.3 => 4.0.3
@graphql-codegen/typescript-react-apollo: ^4.3.2 => 4.3.2
@graphql-codegen/typescript-resolvers: ^4.3.0 => 4.3.0
@graphql-eslint/eslint-plugin: ^3.20.1 => 3.20.1
@hookform/resolvers: ^3.9.0 => 3.9.0
@react-native-community/datetimepicker: 8.0.1 => 8.0.1
@react-navigation/native: ^6.0.2 => 6.1.18
@sentry/react-native: ~5.24.3 => 5.24.3
@tamagui/babel-plugin: ^1.116.12 => 1.116.12
@tamagui/config: ^1.116.12 => 1.116.12
@tamagui/portal: ^1.116.12 => 1.116.12
@tamagui/toast: ^1.116.12 => 1.116.12
@tanstack/react-query: ^5.59.16 => 5.59.16
@types/jest: ^29.5.12 => 29.5.14
@types/react: ~18.2.45 => 18.2.79
@types/react-test-renderer: ^18.0.7 => 18.3.0
axios: ^1.7.7 => 1.7.7
burnt: ^0.12.2 => 0.12.2
eslint: ^8.57.0 => 8.57.1
eslint-config-expo: ^7.1.2 => 7.1.2
eslint-config-prettier: ^9.1.0 => 9.1.0
eslint-config-universe: ^13.0.0 => 13.0.0
eslint-plugin-prettier: ^5.2.1 => 5.2.1
expo: ~51.0.28 => 51.0.38
expo-constants: ~16.0.2 => 16.0.2
expo-dev-client: ~4.0.28 => 4.0.28
expo-device: ~6.0.2 => 6.0.2
expo-font: ~12.0.9 => 12.0.10
expo-linear-gradient: ~13.0.2 => 13.0.2
expo-linking: ~6.3.1 => 6.3.1
expo-notifications: ~0.28.19 => 0.28.19
expo-router: ~3.5.23 => 3.5.23
expo-secure-store: ~13.0.2 => 13.0.2
expo-splash-screen: ~0.27.5 => 0.27.6
expo-status-bar: ~1.12.1 => 1.12.1
expo-system-ui: ~3.0.7 => 3.0.7
expo-updates: ~0.25.27 => 0.25.27
expo-web-browser: ~13.0.3 => 13.0.3
graphql: ^16.9.0 => 16.9.0
graphql-codegen-typescript-validation-schema: ^0.16.0 => 0.16.0
jest: ^29.2.1 => 29.7.0
jest-expo: ~51.0.3 => 51.0.4
prettier: ^3.3.3 => 3.3.3
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-hook-form: ^7.53.1 => 7.53.1
react-native: 0.74.5 => 0.74.5
react-native-gesture-handler: ~2.16.1 => 2.16.2
react-native-reanimated: ~3.10.1 => 3.10.1
react-native-safe-area-context: 4.10.5 => 4.10.5
react-native-screens: 3.31.1 => 3.31.1
react-native-web: ~0.19.10 => 0.19.13
react-test-renderer: 18.2.0 => 18.2.0
tamagui: ^1.116.12 => 1.116.12
typescript: ~5.3.3 => 5.3.3
yup: ^1.4.0 => 1.4.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 10
- Comments: 18 (4 by maintainers)
Will check this one soon
I have the same issue on
1.118.1. I noticed that you can work around the issue if you provide a key whose value changes with the disabled state.For example, modifying the example above:
Same problem here! disabled={booleanState} shows Too many renders problem.
Same problem here!
@natew I can still replicate this with v1.124.18. My buttons look like:
The issue only happens on mobile iOS Safari, not on desktop macOS Safari/Chrome.
Edit: It’s a bit more complicated, in my real code the bug happens even with just the
disabledprop.My dependencies rn:
I can replicate the issue at v1.117.1, using the disabled props causes too many rerenders on safari based browsers on macOS Sequoia and iOS 18. Firefox and Chrome browsers on MacOS and iOS are not affected.
My component is called BigMainButton, all downstream is tamagui code, i couldn’t find any related useEffects in the Button component
This drove me nuts for 2 hours straight 😆 But the key thing worked for now
@jacobffl Was so tensed on this particular issue cuz around 20% of the UI was already done with tamagui. somehow this worked, You are a life saver.