Migration to 3.0.x
WindowInsetsCompat API (BREAKING CHANGE)
With version 3.0.x Android implementation starts using WindowInsetsCompat API. This made library's Android implementation more predictible and less hacky.
As a consequence with version 3.0.x library to handle padding/translation on Android needs to call new method setShouldMimicIOSBehavior
instead of setAdjustNothing
If you upgrade to version 3.0.x (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.0.x 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)
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 or you can stay at 2.x.x, however be aware that it won't be developed (only critical bugs will be handled).