diff --git a/Sources/React/Element/Component.swift b/Sources/React/Element/Component.swift index 91b53ec..7c9f2eb 100644 --- a/Sources/React/Element/Component.swift +++ b/Sources/React/Element/Component.swift @@ -6,44 +6,12 @@ public protocol Component: Element { var deps: Deps? { get } func render() -> Node - - static func _extractGhost(_ input: GhostInput) -> Ghost } extension Component { public var key: AnyHashable? { nil } public var deps: Deps? { nil } - - static func extractGhostDefault(_ input: GhostInput) -> Ghost { - let hooks = extractHooks(input.component) - - return Ghost( - component: input.component, - hooks: hooks - ) - } - - static func extractHooks(_ value: Any) -> [any _AnyHookWrapper] { - var hooks: [any _AnyHookWrapper] = [] - - let mirror = Mirror(reflecting: value) - for mc in mirror.children { - switch mc.value { - case let hook as any _AnyHookWrapper: - hooks.append(hook) - case let hook as any Hook: - hooks += extractHooks(hook) - default: break - } - } - - return hooks - } - - public static func _extractGhost(_ input: GhostInput) -> Ghost { - extractGhostDefault(input) - } } enum Components { diff --git a/Sources/React/Element/Ghost.swift b/Sources/React/Element/Ghost.swift deleted file mode 100644 index 6746c90..0000000 --- a/Sources/React/Element/Ghost.swift +++ /dev/null @@ -1,28 +0,0 @@ -public struct GhostInput { - public init( - component: C - ) { - self.component = component - } - - public var component: C -} - -public struct Ghost { - public var component: any Component - - var hooks: [any _AnyHookWrapper] - var contextValue: (type: any ContextValue.Type, value: any ContextValue)? - - var states: [any _AnyStateHook] { - hooks.compactMap { $0 as? any _AnyStateHook } - } - - var contexts: [any _AnyContextHook] { - hooks.compactMap { $0 as? any _AnyContextHook } - } - - var effects: [any _AnyEffectHook] { - hooks.compactMap { $0 as? any _AnyEffectHook } - } -} diff --git a/Sources/React/Hooks/Context/ContextValueProvider.swift b/Sources/React/Hooks/Context/ContextValueProvider.swift index 1d37e50..16d8088 100644 --- a/Sources/React/Hooks/Context/ContextValueProvider.swift +++ b/Sources/React/Hooks/Context/ContextValueProvider.swift @@ -31,12 +31,6 @@ public struct ContextValueProvider: Component & _AnyContext var _contextValueType: any ContextValue.Type { Value.self } var _contextValue: any ContextValue { value } - - public static func _extractGhost(_ input: GhostInput) -> Ghost { - var ghost = extractGhostDefault(input) - ghost.contextValue = (type: Value.self, value: input.component.value) - return ghost - } } internal protocol _AnyContextValueProvider {