Skip to main content
Version: 2.0.x

Usage - view

import * as React from "react";
import { AvoidSoftInputView } from "react-native-avoid-softinput";

/**
* If you want to use `AvoidSoftInputView` on Android,
* remember to call `setAdjustNothing()` somewhere in the root component
* or inside `useFocusEffect` callback, if you use react-navigation and want to use
* `AvoidSoftInputView` only on specific screen
*
* ```ts
* React.useEffect(() => {
* AvoidSoftInput.setAdjustNothing();
* }, []);
* ```
*/

const MyComponent = () => {
function onSoftInputShown(e) {
// Do sth
}
function onSoftInputHidden() {
// Do sth
}
function onSoftInputHeightChange(e) {
// Do sth
}
function onSoftInputAppliedOffsetChange(e) {
// Do sth
}
return (
<AvoidSoftInputView
avoidOffset={10}
easing="easeIn"
hideAnimationDelay={100}
hideAnimationDuration={300}
onSoftInputShown={onSoftInputShown}
onSoftInputHidden={onSoftInputHidden}
onSoftInputHeightChange={onSoftInputHeightChange}
showAnimationDelay={100}
showAnimationDuration={800}
style={styles.avoidSoftInputView}
>
{/** Content that should be pushed above the keyboard */}
</AvoidSoftInputView>
);
};