0.15.0 • Published 5 months ago

react-native-animateable-text v0.15.0

Weekly downloads
380
License
MIT
Repository
github
Last release
5 months ago

react-native-animateable-text

A fork of React Native's <Text/> component that supports Reanimated Shared Values as text!

Compatibility

(🚨 Make sure you use the correct version for your RN project)

Installation

First make sure you have reanimated already installed and linked from here then run

yarn add react-native-animateable-text

then for Expo managed projects you need to prebuild your project, and for ReactNative bare projects you should run

npx pod-install

Usage (Reanimated 2/3)

Note about Reanimated 2: The library does not work with Alpha 9 until RC1. Make sure to update to RC2 or later!

Use it the same as a <Text/> component, except instead of passing the text as a child node, pass it using the text props.

import AnimateableText from 'react-native-animateable-text';

const Example: React.FC = () => {
  const reanimatedText = useSharedValue('World');

  const animatedProps = useAnimatedProps(() => {
    return {
      text: reanimatedText.value,
    };
  });

  return (
    <AnimateableText
      animatedProps={animatedProps}
      // all other <Text /> props are also available
    />;
};

OMG, why would you build this?

We want to animate numbers based on gestures as fast as possible, for example for charts displaying financial data. Updating native state is too slow and not feasible for a smooth experience. Using createAnimatedComponent doesn't allow you to animate the text since the children of Text are separate nodes rather than just props.

The best way so far has been to use the <ReText> component from react-native-redash, which allows you to render a string from a Reanimated Text node. However, under the hood, it uses a <TextInput/> and animates it's value prop.

This naturally comes with a few edge cases, for example:

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Credits

Written by Jonny Burger for our needs at Axelra.

Thanks to Axelra for sponsoring my time to turn this into an open source project!

License

MIT

0.15.0

5 months ago

0.14.2

8 months ago

0.15.0-beta.0

6 months ago

0.14.0

9 months ago

0.14.1

8 months ago

0.14.0-beta.0

9 months ago

0.13.0

10 months ago

0.12.1

1 year ago

0.12.0

1 year ago

0.11.1

1 year ago

0.11.0

2 years ago

0.10.2

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.0

3 years ago

0.9.1

3 years ago

0.8.1

4 years ago

0.8.2

4 years ago

0.8.0

4 years ago

0.7.0-alpha.0

4 years ago

0.7.0

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.9

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.4

4 years ago

0.5.5

4 years ago

0.5.0

5 years ago

0.3.0

5 years ago

0.4.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago