Skip to content

Commit

Permalink
fix: rm conditional hook (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Jun 2, 2024
1 parent f75dba1 commit ff4bf1c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const textDefaults: TextProps = {
selectable: true
}

function UITextViewInner({
function UITextViewChild({
style,
children,
...rest
Expand Down Expand Up @@ -123,18 +123,11 @@ function UITextViewInner({
}
}

export function UITextView(
function UITextViewInner(
props: TextProps & {
uiTextView?: boolean
}
) {
if (Platform.OS !== 'ios') {
return <RNText {...props} />
}

// This will never actually get called conditionally, so we don't need
// to worry about the warning
// eslint-disable-next-line react-hooks/rules-of-hooks
const [isAncestor] = useTextAncestorContext()

// Even if the uiTextView prop is set, we can still default to using
Expand All @@ -143,5 +136,12 @@ export function UITextView(
if ((!props.selectable || !props.uiTextView) && !isAncestor) {
return <RNText {...props} />
}
return <UITextViewChild {...props} />
}

export function UITextView(props: TextProps & {uiTextView?: boolean}) {
if (Platform.OS !== 'ios') {
return <RNText {...props} />
}
return <UITextViewInner {...props} />
}

0 comments on commit ff4bf1c

Please sign in to comment.