question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add onLayout native events for Reanimated 2

See original GitHub issue

Description

onLayout handler should work on UI thread

Motivation

measure() measures paddings with some infelicity, while onLayout returns correct height/width/etc.

Example

The following example is default accordion animation with opened/closed component inside

  1. Closed => Open transition (height) image

  2. Open => Closed transition (height) image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

19reactions
terrysahaidakcommented, Dec 14, 2020

I would go with that approach. It gives freedom to the developer.

const handler = useAnimatedLayoutEvent((layout) => {
  "worklet";

  // do whatever you want
}, [])

<Animated.View onLayout={handler} />
2reactions
Ubaxcommented, Jan 28, 2022

@terrysahaidak @AlexeyVlasenko Could you open a topic about that in discussion? This is more a feature request then issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Events | React Native Reanimated - Software Mansion
Reanimated 2 integrates tightly with the react-native-gesture-handler package ... Next, we add an event handler to it — it will react to notifications...
Read more >
Developers - Add onLayout native events for Reanimated 2 -
Description. onLayout handler should work on UI thread. Motivation. measure() measures paddings with some infelicity, while onLayout returns correct ...
Read more >
Newest 'react-native-reanimated-v2' Questions - Stack Overflow
What I tried so far: onLayout doesn't fire on reanimated events. ... to start an animation from a button onPress event using React...
Read more >
Animations in React Native: Performance and Reason-about ...
Introducing React Native Reanimated (Version 2) ... Animations alone are a pretty great way to add some polish to a mobile app.
Read more >
React Native Animations: a Guide on Creating ... - UpsilonIT
The worklets can serve as event handlers. It is possible to define a separate worklet for handling each handler state. Though Reanimated version...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found