Skip to content

Commit d338689

Browse files
authored
feat(📘): Allow passing arbitrary props to ReText component (#501)
1 parent 9b33e8e commit d338689

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/ReText.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import type { TextProps as RNTextProps } from "react-native";
2+
import type { TextInputProps, TextProps as RNTextProps } from "react-native";
33
import { StyleSheet, TextInput } from "react-native";
44
import Animated, { useAnimatedProps } from "react-native-reanimated";
55

@@ -10,15 +10,15 @@ const styles = StyleSheet.create({
1010
});
1111
Animated.addWhitelistedNativeProps({ text: true });
1212

13-
interface TextProps {
13+
interface TextProps extends Omit<TextInputProps, "value" | "style"> {
1414
text: Animated.SharedValue<string>;
1515
style?: Animated.AnimateProps<RNTextProps>["style"];
1616
}
1717

1818
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
1919

2020
const ReText = (props: TextProps) => {
21-
const { text, style } = { style: {}, ...props };
21+
const { style, text, ...rest } = props;
2222
const animatedProps = useAnimatedProps(() => {
2323
return {
2424
text: text.value,
@@ -31,7 +31,8 @@ const ReText = (props: TextProps) => {
3131
underlineColorAndroid="transparent"
3232
editable={false}
3333
value={text.value}
34-
style={[styles.baseStyle, style]}
34+
style={[styles.baseStyle, style || undefined]}
35+
{...rest}
3536
{...{ animatedProps }}
3637
/>
3738
);

0 commit comments

Comments
 (0)