This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react"; | |
const useKeydown = (func, dependencies) => { | |
useEffect(() => { | |
document.addEventListener("keydown", func, false); | |
return () => { | |
document.removeEventListener("keydown", func, false); | |
}; | |
}, [func, dependencies]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react"; | |
import { useNavigation } from "@react-navigation/native"; | |
const useOnScreenIsLeft = (func, dependencies) => { | |
const navigation = useNavigation(); | |
useEffect(() => { | |
const unsubscribe = navigation.addListener("blur", () => { | |
func(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getDefaultHeaderHeight } from "@react-navigation/elements"; | |
import { | |
useSafeAreaFrame, | |
useSafeAreaInsets, | |
} from "react-native-safe-area-context"; | |
const useHeaderHeight = () => { | |
const frame = useSafeAreaFrame(); | |
const insets = useSafeAreaInsets(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react"; | |
import { StatusBar } from "react-native"; | |
/** | |
* | |
* @param {"light-content" | "dark-content" | "default"} style | |
* @param {"light-content" | "dark-content" | "default"} cleanup | |
*/ | |
const useStatusBarStyle = (style, cleanup) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from "react"; | |
import { Keyboard } from "react-native"; | |
const useKeyboard = (keyboardDefaultHeight = 250) => { | |
const [isKeyboardVisible, setKeyboardVisible] = useState(false); | |
const [keyboardHeight, setKeyboardHeight] = useState(keyboardDefaultHeight); | |
async function keyboardDidShowHandler(e) { | |
setKeyboardVisible(true); | |
setKeyboardHeight(e.endCoordinates.height); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from "react"; | |
import { BackHandler } from "react-native"; | |
const useBackAction = (func, dependencies) => { | |
useEffect(() => { | |
const backAction = () => { | |
func(); | |
return true; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from "react"; | |
const useTrigger = (func, dependencies) => { | |
const isInitialMount = useRef(true); | |
useEffect(() => { | |
if (isInitialMount.current) { | |
isInitialMount.current = false; | |
} else { | |
func(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"trailingComma": "all", | |
"tabWidth": 2, | |
"semi": true, | |
"singleQuote": false, | |
"useTabs": false, | |
"printWidth": 120, | |
"endOfLine": "auto" | |
} |