Skip to content

Commit

Permalink
feat(📘): Allow passing arbitrary props to ReText component (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyrno42 authored Sep 12, 2022
1 parent 9b33e8e commit d338689
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ReText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import type { TextProps as RNTextProps } from "react-native";
import type { TextInputProps, TextProps as RNTextProps } from "react-native";
import { StyleSheet, TextInput } from "react-native";
import Animated, { useAnimatedProps } from "react-native-reanimated";

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

interface TextProps {
interface TextProps extends Omit<TextInputProps, "value" | "style"> {
text: Animated.SharedValue<string>;
style?: Animated.AnimateProps<RNTextProps>["style"];
}

const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);

const ReText = (props: TextProps) => {
const { text, style } = { style: {}, ...props };
const { style, text, ...rest } = props;
const animatedProps = useAnimatedProps(() => {
return {
text: text.value,
Expand All @@ -31,7 +31,8 @@ const ReText = (props: TextProps) => {
underlineColorAndroid="transparent"
editable={false}
value={text.value}
style={[styles.baseStyle, style]}
style={[styles.baseStyle, style || undefined]}
{...rest}
{...{ animatedProps }}
/>
);
Expand Down

0 comments on commit d338689

Please sign in to comment.