Skip to content

Extract shared request-state boundary for popup data screens #2780

@JakeUrban

Description

@JakeUrban

Follow-up from #2758 (Guard popup views against RequestState.ERROR data dereferences).

Context

PR #2779 fixed the RequestState.ERROR crashes in SwapAmount, SendAmount, and AssetVisibility by hand-applying the same loading → error → reroute → resolved guard sequence already present in AddAsset and Wallets. The pattern is now duplicated across at least five popup screens (AddAsset, Wallets, SwapAmount, SendAmount, AssetVisibility), each with its own __fetch-fail div, <Notification variant="error">, and const data = state.data binding. The next view that wires up a useGetAppData-style hook will almost certainly forget one of these guards and reintroduce the crash class.

What needs to happen

Extract a shared boundary that takes a State<NeedsReRoute | TResolved, E> plus per-screen title / message strings and a children: (data: TResolved) => ReactNode render prop, and returns either the loader, the error Notification, the reroute Navigate, or children(data). Migrate all five existing call sites to use it. Consider a typed useResolvedState projection variant so call sites only ever see the success payload.

Dependencies

None.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upFollow-up from another issue or PR

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions