title: why do we wrap Action with an explicit animation instead of wrapping State change in the Reducer
body: <p>In their series on SwiftUI animation, the PointFree guys recommend we use explicit animations that wrap actions sent to the reducer in order to trigger animations when state is updated.</p>
  <p>My question is why we don't instead wrap the actual State change, performed in the Reducer?</p>
  <p>If I wrap the State change with an explicit animation, nothing happens. But if I wrap the Action being sent to the Reducer, animations work.</p>
  <p>This code below is roughly adapted from <a href="https://www.pointfree.co/episodes/ep136-swiftui-animation-the-basics" rel="nofollow noreferrer">https://www.pointfree.co/episodes/ep136-swiftui-animation-the-basics</a> around minute 16.23</p>
  <p>//works</p>
  <pre class="lang-swift prettyprint-override"><code> TextField(
                           &quot;search&quot;,
                         text: viewStore.binding(get: \.searchText, send:
                                                  TCSearchAction.updateSearch).animation(.easeInOut)
                         )
  </code></pre>
  <p>If I remove the animation call in the binding above, and add it directly  to the state change, animations don't seem to fire.</p>
  <p>// doesn't fire animations</p>
  <pre class="lang-swift prettyprint-override"><code>   static let reducer = Reducer&lt;TCSearchState, TCSearchAction, Void&gt; {state, action, _ in
          
          switch action {
          case let .updateSearch(string):
              //this does not trigger animations when value is changed
              withAnimation(.easeInOut)
              {
                  state.searchText = string
                  
              }
  </code></pre>