Giter Club home page Giter Club logo

Comments (5)

mbrandonw avatar mbrandonw commented on May 29, 2024 1

Hi @jaanussiim, thank you very much for the simple reproducible example. That was very helpful.

I've been able to verify the crash, and I was able to reduce the example a little bit:

struct ParentView: View {
  let store = Store(initialState: Parent.State()) {
    Parent()
  }
  var body: some View {
    Form {
      IfLetStore(
        store.scope(state: \.$child, action: \.child),
        then: ChildView.init(store:),
        else: {
          Button(action: { store.send(.show) }) {
            Text("Show")
          }
        }
      )
    }
  }
}
@Reducer
struct Parent {
  struct State {
    @PresentationState var child: Child.State?
  }
  enum Action {
    case child(PresentationAction<Child.Action>)
    case show
  }
  var body: some ReducerOf<Self> {
    Reduce { state, action in
      switch action {
      case .child(.presented(.dismiss)):
        state.child = nil
        return .none
      case .child:
        return .none
      case .show:
        state.child = Child.State()
        return .none
      }
    }
    .ifLet(\.$child, action: \.child) {
      Child()
    }
  }
}
struct ChildView: View {
  let store: StoreOf<Child>
  var body: some View {
    Button("Dismiss") { store.send(.dismiss) }
  }
}
@Reducer
struct Child {
  struct State {}
  enum Action { case dismiss }
  var body: some ReducerOf<Self> { EmptyReducer() }
}

I've got a fix for the crash, but want to get some tests into place and want to discuss with Stephen too. For now I suggest pinning to 1.5.1 to avoid the problem.

from swift-composable-architecture.

larryonoff avatar larryonoff commented on May 29, 2024

I have the same issue also.

from swift-composable-architecture.

mbrandonw avatar mbrandonw commented on May 29, 2024

@larryonoff @jaanussiim Can y'all try pointing to this branch and see if it fixes the problem for you?

https://github.com/pointfreeco/swift-composable-architecture/compare/store-cache-crash-fix

from swift-composable-architecture.

jaanussiim avatar jaanussiim commented on May 29, 2024

The location where I found the crash is no longer crashing when using branch store-cache-crash-fix

from swift-composable-architecture.

larryonoff avatar larryonoff commented on May 29, 2024

@mbrandonw thanks for the fix! The crash flew away.

from swift-composable-architecture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.