Skip to content

useAnimatedKeyboard initial value is always zero, even if keyboard opened #8328

@gentlee

Description

@gentlee

Description

useAnimatedKeyboard initial value is always zero, even if component mounted when keyboard is opened.

export const AnimatedKeyboardOffset = memo(() => {
	const keyboard = useAnimatedKeyboard()
	const {bottom: bottomInset} = useSafeAreaInsets()

	const heightStyle = useAnimatedStyle(() => {
		return {
			height: interpolate(keyboard.height.value, [0, bottomInset, 400], [bottomInset, bottomInset, 400]),
		}
	}, [bottomInset])
        
    // BUG height is zero when component mounts with keyboard opened
	return <Animated.View style={heightStyle} />
})

Steps to reproduce

  1. Mount component when keyboard is opened.
  2. Hook height value is 0 until you start closing it.

Snack or a link to a repository

Reanimated version

3.4.2

Worklets version

React Native version

0.71.7

Platforms

iOS

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

No response

Device

No response

Host machine

None

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Missing infoThe user didn't precise the problem enoughMissing reproThis issue need minimum repro scenarioPlatform: iOSThis issue is specific to iOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions