Pwa-studio: Refactor ErrorView Component (Scalability)

Created on 6 Jun 2019  路  4Comments  路  Source: magento/pwa-studio

Currently the ErrorView component decides what error message to show based on a series of boolean prop values.

As ErrorView gets more use this isn't exactly scalable.

See this comment for a possible solution.

Also refactor this component to a functional component.

good first issue help wanted

Most helpful comment

So, ErrorView is designed to be a page-level view that reflects server-side routing states:

  • loading
  • notFound
  • internalError

It was not designed to be rendered within other pages as a generic error view, and not designed to have other arbitrary error states added to its internal map. At some point, though, that's exactly what happened: a change was made to the Product component and outOfStock was added to the map.

Here's what I'd like to see:

  • remove outOfStock from ErrorView
  • create a new, more generic component to accommodate new error states
  • remove ErrorView from Product and replace it with the new component

@dani97 I like your concept, and I think it would work for the new component described above.

All 4 comments

@supernova-at @sirugh @jimbo we can refactor this to a function component and create a config map that holds error message, view component location against error code.

The ErrorView Component will receive the error_code as prop and we can get the component lazy loaded at runtime. The view component (like toast, container, alert) can be decided and changed as a config.

Is this good to proceed?

@jimbo had some definitive thoughts on this one so I'll defer to him

So, ErrorView is designed to be a page-level view that reflects server-side routing states:

  • loading
  • notFound
  • internalError

It was not designed to be rendered within other pages as a generic error view, and not designed to have other arbitrary error states added to its internal map. At some point, though, that's exactly what happened: a change was made to the Product component and outOfStock was added to the map.

Here's what I'd like to see:

  • remove outOfStock from ErrorView
  • create a new, more generic component to accommodate new error states
  • remove ErrorView from Product and replace it with the new component

@dani97 I like your concept, and I think it would work for the new component described above.

@jimbo @supernova-at I will work on it now can not assign meself on the issue

Was this page helpful?
0 / 5 - 0 ratings