Skip to content

Commit

Permalink
Merge pull request Expensify#30056 from software-mansion-labs/ts-migr…
Browse files Browse the repository at this point in the history
…ation/rn-text-input-component

[TS migration] Migrate 'RNTextInput.js' component to TypeScript
  • Loading branch information
roryabraham authored Nov 7, 2023
2 parents f7128fe + b7f0930 commit c2e4042
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 51 deletions.
51 changes: 0 additions & 51 deletions src/components/RNTextInput.js

This file was deleted.

29 changes: 29 additions & 0 deletions src/components/RNTextInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, {ForwardedRef} from 'react';
// eslint-disable-next-line no-restricted-imports
import {TextInput, TextInputProps} from 'react-native';
import Animated, {AnimatedProps} from 'react-native-reanimated';

// Convert the underlying TextInput into an Animated component so that we can take an animated ref and pass it to a worklet
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function RNTextInputWithRef(props: TextInputProps, ref: ForwardedRef<React.Component<AnimatedProps<TextInputProps>>>) {
return (
<AnimatedTextInput
allowFontScaling={false}
textBreakStrategy="simple"
ref={(refHandle) => {
if (typeof ref !== 'function') {
return;
}
ref(refHandle);
}}
// eslint-disable-next-line
{...props}
/>
);
}

RNTextInputWithRef.displayName = 'RNTextInputWithRef';

export default React.forwardRef(RNTextInputWithRef);

0 comments on commit c2e4042

Please sign in to comment.