Skip to content
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

Pass sibling to Renderer.mount, fix update order #301

Merged
merged 6 commits into from
Nov 11, 2020

Conversation

MaxDesiatov
Copy link
Collaborator

@MaxDesiatov MaxDesiatov commented Nov 10, 2020

Resolves, but adds no test cases to the test suite for #294. See the issue for the detailed description of the problem.

I will add end-to-end tests for this in future PRs.

I've tested these cases manually so far:

struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        Group {
          Text("true")
          Text("true")
        }
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}

Note the Group view with multiple children in this one, it uncovered required checks for GroupView conformance.

Also tested these more simple cases:

struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        Group {
          // single child
          Text("true")
        }
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}

and

struct Choice: View {
  @State private var choice = false

  var body: some View {
    HStack {
      Button("Trigger") {
        choice.toggle()
      }
      if choice {
        // single child, no nesting
        Text("true")
      } else {
        VStack {
          Text("false")
        }
      }
      Text("end")
    }
  }
}

@MaxDesiatov MaxDesiatov added bug Something isn't working refactor No user-visible functionality change labels Nov 10, 2020
@MaxDesiatov MaxDesiatov requested a review from a team November 10, 2020 22:56
@@ -31,9 +31,6 @@ public protocol Renderer: AnyObject {
*/
associatedtype TargetType: Target

/// Reconciler instance used by this renderer.
var reconciler: StackReconciler<Self>? { get }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't referenced anywhere, so no need to have it as a requirement. It also allowed making this property completely private in Renderer implementations.

@@ -71,7 +71,7 @@ func appendRootStyle(_ rootNode: JSObject) {
}

final class DOMRenderer: Renderer {
private(set) var reconciler: StackReconciler<DOMRenderer>?
private var reconciler: StackReconciler<DOMRenderer>?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still keeping the property implementation itself around, as we need a non-zero retain count on it. The reconciler is really what drives the rendering process.

Copy link
Member

@carson-katri carson-katri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! The original issue was a great catch 😅

@MaxDesiatov MaxDesiatov merged commit 3451d9e into main Nov 11, 2020
@MaxDesiatov MaxDesiatov deleted the renderer-mount-sibling branch November 11, 2020 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working refactor No user-visible functionality change
Development

Successfully merging this pull request may close these issues.

2 participants