Skip to content

MainActors #1147

@xgenem

Description

@xgenem

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @react-native-menu/[email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@react-native-menu/menu/ios/NewArch/FabricMenuViewImplementation.swift b/node_modules/@react-native-menu/menu/ios/NewArch/FabricMenuViewImplementation.swift
index 33d27c5..817270f 100644
--- a/node_modules/@react-native-menu/menu/ios/NewArch/FabricMenuViewImplementation.swift
+++ b/node_modules/@react-native-menu/menu/ios/NewArch/FabricMenuViewImplementation.swift
@@ -6,6 +6,7 @@
 //
 
 import UIKit
+@MainActor
 @available(iOS 14.0, *)
 @objc(FabricMenuViewImplementation)
 public class FabricMenuViewImplementation: MenuViewImplementation, FabricViewImplementationProtocol {
diff --git a/node_modules/@react-native-menu/menu/ios/NewArch/FabricViewImplementationProtocol.swift b/node_modules/@react-native-menu/menu/ios/NewArch/FabricViewImplementationProtocol.swift
index 2cef2fb..cf0c728 100644
--- a/node_modules/@react-native-menu/menu/ios/NewArch/FabricViewImplementationProtocol.swift
+++ b/node_modules/@react-native-menu/menu/ios/NewArch/FabricViewImplementationProtocol.swift
@@ -1,4 +1,5 @@
 import Foundation
+@MainActor
 @objc public protocol FabricViewImplementationProtocol {
     var actions: [NSDictionary]? { get set }
     var title: NSString? { get set }
diff --git a/node_modules/@react-native-menu/menu/ios/OldArch/LegacyActionSheetView.swift b/node_modules/@react-native-menu/menu/ios/OldArch/LegacyActionSheetView.swift
index 3cd1a25..aaeefbc 100644
--- a/node_modules/@react-native-menu/menu/ios/OldArch/LegacyActionSheetView.swift
+++ b/node_modules/@react-native-menu/menu/ios/OldArch/LegacyActionSheetView.swift
@@ -1,3 +1,4 @@
+@MainActor
 @objc(LegacyActionSheetView)
 public class LegacyActionSheetView: ActionSheetView {
     @objc var onPressAction: RCTDirectEventBlock?
diff --git a/node_modules/@react-native-menu/menu/ios/OldArch/LegacyMenuViewImplementation.swift b/node_modules/@react-native-menu/menu/ios/OldArch/LegacyMenuViewImplementation.swift
index 6a2a205..50b1b2d 100644
--- a/node_modules/@react-native-menu/menu/ios/OldArch/LegacyMenuViewImplementation.swift
+++ b/node_modules/@react-native-menu/menu/ios/OldArch/LegacyMenuViewImplementation.swift
@@ -1,5 +1,6 @@
 import UIKit
 @available(iOS 14.0, *)
+@MainActor
 @objc(LegacyMenuViewImplementation)
 public class LegacyMenuViewImplementation: MenuViewImplementation {
     @objc var onPressAction: RCTDirectEventBlock?
diff --git a/node_modules/@react-native-menu/menu/ios/Shared/RCTAlertAction.swift b/node_modules/@react-native-menu/menu/ios/Shared/RCTAlertAction.swift
index 9834131..5058d59 100644
--- a/node_modules/@react-native-menu/menu/ios/Shared/RCTAlertAction.swift
+++ b/node_modules/@react-native-menu/menu/ios/Shared/RCTAlertAction.swift
@@ -53,7 +53,7 @@ class RCTAlertAction {
         
     }
     
-    func createAction(_ handleEvent: @escaping ((String) -> Void)) -> UIAlertAction? {
+    @MainActor func createAction(_ handleEvent: @escaping ((String) -> Void)) -> UIAlertAction? {
         if self.isHidden {
             return nil
         }
diff --git a/node_modules/@react-native-menu/menu/ios/Shared/RCTMenuItem.swift b/node_modules/@react-native-menu/menu/ios/Shared/RCTMenuItem.swift
index bb6bb2b..ece26e7 100644
--- a/node_modules/@react-native-menu/menu/ios/Shared/RCTMenuItem.swift
+++ b/node_modules/@react-native-menu/menu/ios/Shared/RCTMenuItem.swift
@@ -96,7 +96,7 @@ class RCTMenuAction {
 
     }
 
-    func createUIMenuElement(_ handler: @escaping UIActionHandler) -> UIMenuElement {
+    @MainActor func createUIMenuElement(_ handler: @escaping UIActionHandler) -> UIMenuElement {
         if subactions.count > 0 {
             var subMenuActions: [UIMenuElement] = []
             subactions.forEach { subaction in

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions