Learn how to build components once and reuse them everywhere
shape
of the data, this usually happens when the component is made to be used
in several different places (there is even a possibility between using it
between different sites) without having to read from some API specific, i.e.
without any external dependencies (a.k.a implicit dependency).
An example of a universal component is the
Fashion Store ProductShelf,
let’s take a look at it;
Product
type is a type created by a central
entity on schema.org
. Another possible way of thinking about our ProductShelf
would be to write an Inline Loader
and make this inline loader read the API data of an e-commerce in specific (e.g
Shopify) and only then render the ProductShelf.
This is totally possible and doable, however, it should be noted that when this
is done, our business user loses the possibility of, for example, switch
datasource from Shopify to VTEX, which is a very powerful to avoid lock-in on a
specific platform. In that sense, one universal component causes dependencies on
types to be inverted, while instead of the component depending on the API,
actually the component only depends on the data format
and allows loaders
to
be implemented in order to return this type in common, making it possible to
choose the data loader when configuring component properties in the Admin
Editor.