跳转至
Structure

EquatableView

A view type that compares itself against its previous value and prevents its child updating if its new value is the same as its old value.

Declaration

@frozen struct EquatableView<Content> : View where Content : Equatable, Content : View

Overview

To achieve this same effect, use the equatable() modifier.

Two great articles on equatable views are here:

struct ContentView: View {
    @State private var bodyDoesntDependOnMe = false
    var body: some View {
        EquatableView(content: ConformingToEquatableView())
    }
}

struct ConformingToEquatableView: View, Equatable {
    var body: some View {
        Text("I can be optimized using equatable! ⚖️")
    }
}
An EquitableView containing a call to a view with the text "I can be optimized using equatable! ⚖️".

Availability

iOS 13.0+

macOS 10.15+

tvOS 13.0+

watchOS 6.0+

Topics


Initializer

init(content:) Creates a new equatable view from a view.


Instance Property

content The current content view that appears in the equatable view.


Type Alias

Body The type of view representing the body of this view.