Created
August 21, 2023 13:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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