-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement useKeyboardEffect #205
base: main
Are you sure you want to change the base?
feat: implement useKeyboardEffect #205
Conversation
Has anyone with merge permission? |
Hey @hosseinmd , I'm looking at your PR and can't really understand (neither from the example nor code) how you return the keyboard height as animated value. From my understanding, you simply listen to to some events as the regular useKeyboard, which provides a static value, not an animated one. Or am I mistaking and the value is actually animated? |
You could use this hook to create any animated value like "React-native-reanimated" or "React-native" animated value. I provided an example for you. import {useKeyboardEffect} from '@react-native-reanimated'
import {Animated} from 'react-native'
const App = () => {
const keyboardHeightAnim = new Animated.Value(0)
useKeyboardEffect((type, event) => {
keyboardHeightAnim.setValue(event.endCoordinates.height)
}, [])
} |
I see. did you check, how often does the event.endCoordinates.height get called (thus updated) ? In order to provide a smooth animation, it should be at 60fps, which because it crosses the bridge is going to be subject to interference from the JS thread being loaded. What I initially thought when reading the name was that the animated value is actually updated in Native Thread, just like we do with onScroll. Otherwise, it's just a simple state that get's updated in the JS with the keyboard height |
I used React-native Keyboard.addListener on this hook, that is JS side, if we want to run that on native side need to code for natives that's ok, but problem is where we want to use that for another things. |
hi, how can i get this useKeyboardEffect? newest version does not contain this |
Summary
#81
This function is very useful in cases where we need to work with animated or something needed to listen keyboard
Test Plan
Example:
What's required for testing (prerequisites)?
What are the steps to reproduce (after prerequisites)?
Compatibility
Checklist
README.md