Action freezes the UI

Hello,

I have a UITextField and a registered textFieldEditingDidChange every time the text changes I'm sending and action to the reducer

viewStore.send(.textChanged(text: sender.text ?? ""))

in my reducer:

case let . textChanged(text):
state.description = text

if I setup the description variable to the text the UITextField freezes for one second any ideas?

This is happening when the UITextField is embedded inside a UICollectionViewCel.In cellForRow function:

 func collectionView( _ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) ->     UICollectionViewCell {
     cell.store = self?.store?.scope(
     state: { $0.data[indexPath.row] },
     action: { .myEvent(index: indexPath.row, action: $0) }
     )
}

and the code inside the cell:

 var store: Store<DataState, DataAction>? {
    didSet {
        guard let store = store else {
            return
        }
        
     viewStore = ViewStore(store)
  }

@IBAction func textFieldEditingDidChange(_ sender: Any) {
    viewStore?.send(.updateText(sender.text ?? ""))
}

Any ideas why the UI freezes when I'm typing into the UITextField and changing the state of description?:

case let . textChanged(text):
state.description = text
Terms of Service

Privacy Policy

Cookie Policy