ForEachStore & TabView tag

Hello there!
I'm trying to implement ForEachStore within a TabView + PageStyle
Here is my childView's state (reduced state):

public struct State: Equatable, Identifiable {
  // MARK: Internal
  public let id: String
  public let index: Int
  public init( index: Int) {
    self.index = index = index.description

In my parent's view I'm doing this to implement a PagedStyle TabView.

func contentView(
    singleBooking: CarEntrySteps.Infos.SingleBooking,
    store: CarEntrySteps.Store,
    viewStore: CarEntrySteps.ViewStore
) -> some View {
    TabView(selection: viewStore.presentedStepIndexBinding) {
            then: CarEntryInitialStep.View.init(store:)
        ForEachStore(store.carAccessSteps) { store in
            CarEntryStep.View(store: store)
        PageTabViewStyle(indexDisplayMode: .never)
          count: viewStore.entryStepsCount,
          selectedIndex: viewStore.presentedStepIndexBinding
        alignment: .bottom

Everything is working as expected but my question is here:

CarEntryStep.View(store: store)

Is it okay, to init a temporary ViewStore just to get access to my index property on that child state ?


@Pwyll28 It's okay to access the state for index like you are. Sometimes I'd even create an additional view scoped to the index. You'd probably just want to make sure your parent view store CarEntrySteps.ViewStore isn't causing ForEachStore to recalculate unnecessarily.