react-native-is-edge-to-edge
For library authors, we provide this lightweight package, which checks whether react-native-edge-to-edge
is installed, making it easy to update your library accordingly:
API
import {
controlEdgeToEdgeValues,
isEdgeToEdge,
} from "react-native-is-edge-to-edge";
const EDGE_TO_EDGE = isEdgeToEdge();
function MyAwesomeLibraryComponent({
statusBarTranslucent,
navigationBarTranslucent,
}) {
if (__DEV__) {
controlEdgeToEdgeValues({
statusBarTranslucent,
navigationBarTranslucent,
});
}
return (
<MyAwesomeLibraryNativeComponent
statusBarTranslucent={EDGE_TO_EDGE || statusBarTranslucent}
navigationBarTranslucent={EDGE_TO_EDGE || navigationBarTranslucent}
// …
/>
);
}
If you want to check for the library's presence on the native side to bypass certain parts of your code, consider using this small utility:
object EdgeToEdgeUtil {
val ENABLED: Boolean
get() = try {
Class.forName("com.zoontek.rnedgetoedge.EdgeToEdgePackage")
true
} catch (exception: ClassNotFoundException) {
false
}
}