Skip to content

Commit

Permalink
add review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
robertKozik committed Feb 12, 2024
1 parent 7c6f4c3 commit fd779ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/Composer/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {ForwardedRef} from 'react';
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
import type {TextInput} from 'react-native';
import {StyleSheet} from 'react-native';
import type {AnimatedTextInputRef} from '@components/RNMarkdownTextInput';
import type {AnimatedMarkdownTextInputRef} from '@components/RNMarkdownTextInput';
import MarkdownTextInput from '@components/RNMarkdownTextInput';
import useMarkdownStyle from '@hooks/useMarkdownStyle';
import useResetComposerFocus from '@hooks/useResetComposerFocus';
Expand Down Expand Up @@ -31,7 +31,7 @@ function Composer(
}: ComposerProps,
ref: ForwardedRef<TextInput>,
) {
const textInput = useRef<AnimatedTextInputRef | null>(null);
const textInput = useRef<AnimatedMarkdownTextInputRef | null>(null);
const {isFocused, shouldResetFocus} = useResetComposerFocus(textInput);
const theme = useTheme();
const markdownStyle = useMarkdownStyle();
Expand All @@ -42,7 +42,7 @@ function Composer(
* Set the TextInput Ref
* @param {Element} el
*/
const setTextInputRef = useCallback((el: AnimatedTextInputRef) => {
const setTextInputRef = useCallback((el: AnimatedMarkdownTextInputRef) => {
textInput.current = el;
if (typeof ref !== 'function' || textInput.current === null) {
return;
Expand Down
16 changes: 8 additions & 8 deletions src/components/RNMarkdownTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ import Animated from 'react-native-reanimated';
import useTheme from '@hooks/useTheme';

// 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(MarkdownTextInput);
const AnimatedMarkdownTextInput = Animated.createAnimatedComponent(MarkdownTextInput);

type AnimatedTextInputRef = typeof AnimatedTextInput & TextInput & HTMLInputElement;
type AnimatedMarkdownTextInputRef = typeof AnimatedMarkdownTextInput & TextInput & HTMLInputElement;

function RNMarkdownTextInput(props: MarkdownTextInputProps, ref: ForwardedRef<AnimatedTextInputRef>) {
function RNMarkdownTextInputWithRef(props: MarkdownTextInputProps, ref: ForwardedRef<AnimatedMarkdownTextInputRef>) {
const theme = useTheme();

return (
<AnimatedTextInput
<AnimatedMarkdownTextInput
allowFontScaling={false}
textBreakStrategy="simple"
keyboardAppearance={theme.colorScheme}
ref={(refHandle) => {
if (typeof ref !== 'function') {
return;
}
ref(refHandle as AnimatedTextInputRef);
ref(refHandle as AnimatedMarkdownTextInputRef);
}}
// eslint-disable-next-line
{...props}
/>
);
}

RNMarkdownTextInput.displayName = 'RNTextInputWithRef';
RNMarkdownTextInputWithRef.displayName = 'RNTextInputWithRef';

export default React.forwardRef(RNMarkdownTextInput);
export type {AnimatedTextInputRef};
export default React.forwardRef(RNMarkdownTextInputWithRef);
export type {AnimatedMarkdownTextInputRef};

0 comments on commit fd779ad

Please sign in to comment.