Skip to content

Commit

Permalink
fix(ios): thread race of componentDataByName in UIManager2
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Mar 28, 2024
1 parent d2d7f92 commit 2235a15
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions renderer/native/ios/renderer/HippyUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1433,17 +1433,18 @@ - (void)addPropertyEvent:(const std::string &)name
BOOL canBePreventedInCapturing = [view canBePreventedByInCapturing:name.c_str()];
BOOL canBePreventedInBubbling = [view canBePreventInBubbling:name.c_str()];
__weak id weakSelf = self;
std::string name_ = name;
[view addPropertyEvent:[mapToEventName UTF8String] eventCallback:^(NSDictionary *body) {
id strongSelf = weakSelf;
if (strongSelf) {
[strongSelf domNodeForComponentTag:node_id onRootNode:rootNode resultNode:^(std::shared_ptr<DomNode> domNode) {
if (domNode) {
if (domNode && name_.length() > 0) {
HippyValue value = [body toHippyValue];
std::shared_ptr<HippyValue> domValue = std::make_shared<HippyValue>(std::move(value));
auto event = std::make_shared<DomEvent>(name, domNode, canBePreventedInCapturing,
auto event = std::make_shared<DomEvent>(name_, domNode, canBePreventedInCapturing,
canBePreventedInBubbling, domValue);
domNode->HandleEvent(event);
[strongSelf domEventDidHandle:name forNode:node_id onRoot:root_id];
[strongSelf domEventDidHandle:name_ forNode:node_id onRoot:root_id];
}
}];
}
Expand Down

0 comments on commit 2235a15

Please sign in to comment.