Skip to content

Instantly share code, notes, and snippets.

@DarlonHenrique
Created August 21, 2023 13:38
Show Gist options
  • Save DarlonHenrique/a7a76367cd2f38d7fbe1c3f5b2ea8623 to your computer and use it in GitHub Desktop.
Save DarlonHenrique/a7a76367cd2f38d7fbe1c3f5b2ea8623 to your computer and use it in GitHub Desktop.
helper to dismiss the keyboard on React Native when click on the view
import { StyledComponent } from 'nativewind'
import React from 'react';
import { TouchableWithoutFeedback, Keyboard, View } from 'react-native';
interface DismissKeyboardViewProps {
children: React.ReactNode
className?: string
}
export function DismissKeyboardView({children, ...props}: DismissKeyboardViewProps) {
return (
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()} accessible={false}>
<StyledComponent component={View} {...props}>
{children}
</StyledComponent>
</TouchableWithoutFeedback>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment