-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
onLayout is not triggered when Animated.event applied on iOS #24219
Comments
It looks like you are using an older version of React Native. Please update to the latest release, v0.59 and verify if the issue still exists. The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running `react-native info` on a project using the latest release.
|
Updated version |
Also, tried to make @interface RCTOnLayoutEvent : NSObject <RCTEvent>
- (instancetype)initWithReactTag:(NSNumber *)reactTag
content:(NSDictionary *)content;
@end
@implementation RCTOnLayoutEvent
{
NSDictionary *_content;
}
@synthesize viewTag = _viewTag;
@synthesize coalescingKey = _coalescingKey;
- (instancetype)initWithReactTag:(NSNumber *)reactTag
content:(NSDictionary *)content
{
static uint16_t coalescingKey = 0;
if ((self = [super init])) {
_coalescingKey = coalescingKey++;
_viewTag = reactTag;
_content = content;
}
return self;
}
RCT_NOT_IMPLEMENTED(- (instancetype)init)
- (uint16_t)coalescingKey
{
return _coalescingKey;
}
- (NSString *)eventName
{
return @"onLayout";
}
- (BOOL)canCoalesce
{
return NO;
}
+ (NSString *)moduleDotMethod
{
return @"RCTEventEmitter.receiveEvent";
}
- (NSArray *)arguments
{
return @[self.viewTag, @"topLayout", _content];
}
- (id<RCTEvent>)coalesceWithEvent:(id<RCTEvent>)newEvent {
return newEvent;
}
@end NSDictionary *content = @{
@"layout": @{
@"x": @(frame.origin.x),
@"y": @(frame.origin.y),
@"width": @(frame.size.width),
@"height": @(frame.size.height),
},
};
// shadowView.onLayout(content);
RCTOnLayoutEvent *layoutEvent = [[RCTOnLayoutEvent alloc] initWithReactTag:reactTag
content:content]; And it worked but events are being attached after mounting so this event is dispatching after filling a map with proper values in Native Animated Module. |
Sorry I missed this, events defined with Event improvement PR (prereq, merged): #15894 It should still work but just needs to be rebased on top of #15894 |
In the meantime, has anyone been able to work around this issue? It seems there's no way to re-read the layout at all, and in my current implementation moving from an |
Yeah - same here - this has taken up my whole day now. Thought it was going to be a 5 min bug when i first saw it. This happened after upgrade from 0.57 - 0.59.10 Annoyingly any fix now will be added to > .6 versions and thats not an option for me right now, so need ti figure out a work around. |
Any news about this issue ? |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
@yairopro Seems like a bug with react-native-reanimated, I changed your example to use Animated and it seems so work fine on Android. https://snack.expo.io/@janic/onlayout-=-animated.event(..)-not-working |
@osdnk Also works in Expo now so I assume my fix made it to a release, if you want to close this (Looks like I don't have the power to close issues anymore :() |
(that's super weird! lmk if you want to close it) |
@kelset yes please! |
🐛 Bug Report
Behavior on Adnroid is expected one.
To Reproduce
Apply valued to
transform
and bind withAnimated.event
set toonLayout
prop inAnimated.View
.Expected Behavior
iOS should look like Android here. The value should hold a result of Animated.event's invocation.
Code Example
Environment
The text was updated successfully, but these errors were encountered: