The SwiftUI tutorial uses the @State
keyword to indicate mutable UI state:
@State var showFavoritesOnly = false
It offers this summ
Let me add something else if you know React Native.
The @State
property is very like the this.state
object in React Native.
For example:
struct Foobar: some View {
@State var username = ""
}
class Foobar extends React.Component {
constructor(props) {
super(props);
this.state = {
username: '',
};
}
}
When you modify the username variable, they will have the same effect, that re-render the current page.