강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

랑프_Langpeu님의 프로필 이미지
랑프_Langpeu

작성한 질문수

SwiftUI + TCA: 실전 프로젝트로 완성하는 차세대 iOS 아키텍처

AlertState 활용하여 Alert 띄우기 & 부모에서 Scope 액션 감지하기

TextField 에 Binding 으로 연결하면 에러 발생

작성

·

10

0

강의 내용중에

아래 2가지가 가능하다고 했는데

1번

TextField("이메일을 입력해주세요", text: $store.email.sending(\.inputEmail))

2번

            TextField("이메일을 입력해주세요", text: Binding(get: {

                store.email

            }, set: { email in

                store.send(.inputEmail(email))

            }))

2번 코드로 작성후 이메일주소를 수정후
저장 하니깐 아래와 같은 에러가 발생했습니다.

A "forEach" at "AppStore/MyPageReducer.swift:96" received an action for a missing element.

  Action:
    MyPageStackReducer.Action.email(.inputEmail)

This is generally considered an application logic error, and can happen for a few reasons:

A parent reducer removed an element with this ID before this reducer ran. This reducer must run before any other reducer removes an element, which ensures that element reducers can handle their actions while their state is still available.

An in-flight effect emitted this action when state contained no element at this ID. While it may be perfectly reasonable to ignore this action, consider canceling the associated effect before an element is removed, especially if it is a long-living effect.

This action was sent to the store while its state contained no element at this ID. To fix this make sure that actions for this reducer can only be sent from a store when its state contains an element at this id. In SwiftUI applications, use "NavigationStack.init(path:)" with a binding to a store.


확인해 보니 pop시 Binding의 set 이 호출되서

이미 path에 없는 element를 호출하게 되서

해당 에러가 발생한다고 합니다.

그럼 TCA 환경에서는 1번을 꼭 사용해야 하는 건지요 ?

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
랑프_Langpeu님의 프로필 이미지
랑프_Langpeu

작성한 질문수

질문하기