ampproject / amp-react-prototype

A scratch pad to experiment with React rendered AMP Components
Apache License 2.0
36 stars 9 forks source link

AMP Context and service propagation #49

Open dvoytenko opened 4 years ago

dvoytenko commented 4 years ago

This is similar to property and contexts (see #48). We could place services as a map in the AmpContext or we could break them down a service-per-context. We could also consider passing services via component props.

In other words, it's either:

<AmpLightbox
    backButton={backButtonService}
    ></AmpLightbox>

vs

<BackButtonContext.Provider value={backButtonService}>
  <AmpLightbox></AmpLightbox>
</BackButtonContext.Provider>

Whether or not we use a single or per-service context: this could be a significant performance optimization since only the dependent components need to be re-rendered when a service changes.