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
Follow-up from #2758 (Guard popup views against
RequestState.ERRORdata dereferences).Context
PR #2779 fixed the
RequestState.ERRORcrashes 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-faildiv,<Notification variant="error">, andconst data = state.databinding. The next view that wires up auseGetAppData-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-screentitle/messagestrings and achildren: (data: TResolved) => ReactNoderender prop, and returns either the loader, the errorNotification, the rerouteNavigate, orchildren(data). Migrate all five existing call sites to use it. Consider a typeduseResolvedStateprojection variant so call sites only ever see the success payload.Dependencies
None.
References