Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated thousandths place digit #16

Open
jyaconelli opened this issue Oct 1, 2024 · 0 comments
Open

Duplicated thousandths place digit #16

jyaconelli opened this issue Oct 1, 2024 · 0 comments

Comments

@jyaconelli
Copy link

jyaconelli commented Oct 1, 2024

Bug description

The digit in the thousandths place gets doubled whenever you spin to a number with at least 4 digits

Version

1.0.12

Reproduction

https://snack.expo.dev/@jyaconelli/duplicate-first-digit-repro

Code

import { Button, SafeAreaView, StyleSheet } from 'react-native';
import SpinningNumbers from '@birdwingo/react-native-spinning-numbers';
import { useState } from 'react';

const numbers = [123, 4567];

export default function App() {
  const [currentNumberIdx, setCurrentNumberIdx] = useState(0);

  return (
    <SafeAreaView style={styles.container}>
      <SpinningNumbers>{numbers[currentNumberIdx]}</SpinningNumbers>
      <Button
        title="Change number"
        onPress={() =>
          setCurrentNumberIdx((currentNumberIdx + 1) % numbers.length)
        }
      />
    </SafeAreaView>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

Video

In the video, it is switching between two numbers: 4321 and 234, however the 4 or 4321 gets reliably repeated

ScreenRecording_10-01-2024.16-55-27_1.MP4

Additional notes

  • If numbers are formatted with comma delineation (i.e. 1,000 instead of 1000) this solves the doubled digit issue. However, then the spinning animation doesn't trigger when going from a number with less than 4 digits to a number with at least 4 digits (i.e. 123 to 4321)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant