1

The screen is Wrapped inside KeyboardAvoidingView and ScrollView components. Some of the last inputs are partially hidden by the keyboard. If I set the behaviour prop to anything, but undefined a white element comes up after keyboard. All I would like to do is to make the screen scroll down like 20 more pixels... I feel like I have tried everything so far, even setting the keyboardVerticalOffset prop, but nothing seems to work. If that offset was transparent it would be perfect...

In the following code a View component is passed to children prop

import { FunctionComponent, ReactNode } from 'react';
import { KeyboardAvoidingView, ScrollView } from 'react-native';

interface WrapperProps {
  children: ReactNode;
}

const KeyboardAvoidingWrapper: FunctionComponent<WrapperProps> = ({children}) => {
  return (
    <KeyboardAvoidingView behavior='height' keyboardVerticalOffset={100}>
      <ScrollView>
        {children}
      </ScrollView>
    </KeyboardAvoidingView>
  );
};

enter image description here

Nandor Krizbai
  • 89
  • 2
  • 11

2 Answers2

1

Instead, You can use react-native-keyboard-aware-scroll-view.

bb14816
  • 473
  • 1
  • 5
  • 14
1

I solved my issue with: react-native-avoid-softinput

INSTALLATION:

yarn add react-native-avoid-softinput

On iOS additionally run: npx pod-install

USAGE:

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

const MyComponent = () => {
  return (
    <AvoidSoftInputView>
      {/** Content that should be pushed above the keyboard */}
    </AvoidSoftInputView>
  );
};

TROUBLESHOOTING:

requireNativeComponent: "AvoidSoftInputView" was not found in the UIManager.

Solution: https://stackoverflow.com/a/65513391/14056591

Try again cd ios && pod install

If it doesn't help, try restarting the simulator, delete and rebuild the app. Restarting Xcode and metro bundler is also a good idea.

If this does not solve your issue, I came across another promising library, but I did not get to use it: react-native-keyboard-controller

Ovidiu Cristescu
  • 821
  • 7
  • 19
  • 1
    Thanks for the reply, the second library won't work for me and the first one gives the error: `requireNativeComponent: "AvoidSoftInputView" was not found in the UIManager.` – Nandor Krizbai Sep 11 '22 at 12:13
  • 1
    @NándorKrizbai Check updated answer I personally had lots of issues with react-native-aware-scroll-view and that’s how I got to the mentioned library – Ovidiu Cristescu Sep 11 '22 at 13:22
  • 1
    Indeed, the aware-scroll-view is not working perfectly on IOS. I think I'm unable to use `react-native-avoid-softinput`, because it's an Expo project. I would need to eject to ExpoKit, which I can't do right now... – Nandor Krizbai Sep 11 '22 at 17:53
  • 1
    https://stackoverflow.com/questions/61967017/invariant-violation-requirenativecomponent-rncsafeareaprovider-was-not-found - You can also try solutions from Expo here. Sorry, I don't have much experience with Expo. – Ovidiu Cristescu Sep 11 '22 at 21:50
  • I tried all the solutions, I think it's just not supported in Expo yet... – Nandor Krizbai Sep 12 '22 at 06:46