Migration from 2.x.x
WindowInsetsCompat API (BREAKING CHANGE)
From version 3.x.x Android implementation starts using WindowInsetsCompat API. This made library's Android implementation more predictible and less hacky.
As a consequence, from version 3.x.x onwards library to handle padding/translation on Android needs to call new method setShouldMimicIOSBehavior
instead of setAdjustNothing
If you upgrade to version 3.x.x or newer (and you don't use setAdjustNothing
or setDefaultAppSoftInputMode
intentionally to handle sth else then library's correct usage on Android), just replace all setAdjustNothing
(and setDefaultAppSoftInputMode
) calls with setShouldMimicIOSBehavior(<boolean-value>)
.
Example
/**
* If module in your app is always enabled,
* just change `setAdjustNothing` with `setShouldMimicIOSBehavior(true)`
*/
useEffect(() => {
- AvoidSoftInput.setAdjustNothing(); // <---- Set windowSoftInputMode on Android to match iOS behavior
+ AvoidSoftInput.setShouldMimicIOSBehavior(true); // <---- Tell Android that library will handle keyboard insets manually to match iOS behavior
AvoidSoftInput.setEnabled(true); // <---- Enable module
}, []);
/**
* If you used module only in specific screen with react-navigation,
* change `setAdjustNothing` with `setShouldMimicIOSBehavior(true)`
* and replace `setDefaultAppSoftInputMode` with `setShouldMimicIOSBehavior(false)`
*/
const onFocusEffect = useCallback(() => {
- AvoidSoftInput.setAdjustNothing(); // <---- Set windowSoftInputMode on Android to match iOS behavior
+ AvoidSoftInput.setShouldMimicIOSBehavior(true); // <---- Tell Android that library will handle keyboard insets manually to match iOS behavior
AvoidSoftInput.setEnabled(true); // <---- Enable module
return () => {
AvoidSoftInput.setEnabled(false);
- AvoidSoftInput.setDefaultAppSoftInputMode();
+ AvoidSoftInput.setShouldMimicIOSBehavior(false);
};
}, []);
useFocusEffect(onFocusEffect);
Support for Fabric & TurboModules
From version 3.x.x onwards library supports RN's new architecture in projects with RN version >= 0.70. Autolinking of Fabric & TurboModule library version is handled automatically with projects using @react-native-community/cli
version >= 9.0.0 (support was implemented with this commit)
Bumping minimal supported React Native and iOS versions (BREAKING CHANGE)
Version 4.x.x and later
This library follows the React Native releases support policy. It is supporting the latest version, and the two previous minor series.
You may find it working correctly with some older React Native versions, but it'll be a "Use at your own risk" case.
Version 3.x.x
As a result of introducing support for Fabric & TurboModules library bumped its minimal supported RN version (on old architecture) to 0.65 and minimal supported iOS version to 11.0.
If you use library on older project (RN version <= 0.64), you have to upgrade RN to version >= 0.65.