Skip to content

Commit

Permalink
Update useKeyboard hook to use default argument for `shouldHandleKe…
Browse files Browse the repository at this point in the history
…yboardEvents` (#265)

* update useKeyboard argument shouldHandleKeyboardEvents to default to true

* Add changesets patch bump for useKeyboard hook
  • Loading branch information
JDMathew authored Oct 12, 2024
1 parent 95e3cae commit ed9b693
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-planets-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-native-ama/extras': patch
---

Updated useKeyboard hook argument shouldHandleKeyboardEvents to default to true and not be required.
6 changes: 3 additions & 3 deletions packages/extras/src/hooks/useKeyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ const KEYBOARD_EVENT_HIDE: KeyboardEventName = Platform.select({
default: 'keyboardDidHide',
});

export const useKeyboard = (shouldHandleKeyboardEvents: boolean) => {
export const useKeyboard = (shouldHandleKeyboardEvents: boolean = true) => {
const keyboardHeight = useSharedValue(0);
const keyboardFinalHeight = useSharedValue(0);
const isKeyboardVisible = useSharedValue(false);

const handleKeyboardEvent = useCallback(
(
isVisible: boolean,
height: number,
endCoordinatesHeight: number,
duration: number,
easing: KeyboardEventEasing,
) => {
const finalHeight = isVisible ? height : 0;
const finalHeight = isVisible ? endCoordinatesHeight : 0;

const animationConfig = getKeyboardAnimationConfigs(easing, duration);

Expand Down

0 comments on commit ed9b693

Please sign in to comment.