You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`AtomDerivedScope` is useful when, for some reason, the atom store is not propagated through a view hierarchy. It explicitly propagate the atom store from the parent view via the given view context.
`Suspense` awaits the resulting value of the given `Task` and displays the content depending on its phase.
@@ -1476,20 +1493,6 @@ AtomScope {
1476
1493
}
1477
1494
```
1478
1495
1479
-
If you want to inherit the overridden atom from the parent scope, you can explicitly pass `@ViewContext` context that has gotten in the parent scope. Then, the new scope completely inherits the parent scope's context.
1480
-
1481
-
```swift
1482
-
@ViewContext
1483
-
var context
1484
-
1485
-
var body: some {
1486
-
// Inherites the parent scope's overrides.
1487
-
AtomScope(inheriting: context) {
1488
-
CountDisplay()
1489
-
}
1490
-
}
1491
-
```
1492
-
1493
1496
Note that overridden atoms in `AtomScope` automatically be scoped, but other atoms that depend on them will be in a shared state and must be given `Scoped` attribute (See also: [Scoped Atom](#scoped-atom)) in order to avoid it from being shared across out of scope.
1494
1497
1495
1498
See [Testing](#testing) section for details on dependency injection on unit tests.
@@ -1803,7 +1806,7 @@ class MessageLoader: ObservableObject {
1803
1806
#### Modal presentation causes assertionFailure when dismissing it (Fixed in iOS15)
1804
1807
1805
1808
Unfortunately, SwiftUI has a bug in iOS14 or lower where the `EnvironmentValue` is removed from a screen presented with `.sheet` just before dismissing it. Since this library is designed based on `EnvironmentValue`, this bug end up triggering the friendly `assertionFailure` that is added so that developers can easily aware of forgotten `AtomRoot` implementation.
1806
-
As a workaround, `AtomScope` has the ability to explicitly inherit the store through`AtomViewContext` from the parent view.
1809
+
As a workaround, you can use `AtomDerivedScope` to explicitly propagate the atom store via`AtomViewContext` from the parent view.
1807
1810
1808
1811
<details><summary><code>💡 Click to expand workaround</code></summary>
0 commit comments