fix(ep-commerce): mark EPProductProvider as providesData#332
Merged
Conversation
Without this flag Plasmic compiles the component's slot inline at the parent's render scope, so `$ctx.currentProduct.*` bindings inside the slot evaluate where currentProduct doesn't exist yet (the DataProvider the component publishes only takes effect for descendants). Setting providesData makes the compiler wrap the slot in a descendant function component with its own useDataEnv, where currentProduct resolves. Matches sibling data-providing components in the same package (EPCartProvider, EPBundleProvider, EPVariationPicker, etc.) which all already declare providesData: true.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EPProductProvider:providesData: true.childrenslot inline at the parent's render scope, so$ctx.currentProduct.*bindings inside the slot evaluate wherecurrentProductdoesn't exist yet (the<DataProvider name="currentProduct">the component publishes only takes effect for descendants).useDataEnv()—currentProductresolves correctly and PDPs that wireproductto a Plasmic Server Query ($q.<name>.data) actually render the product data instead of throwingTypeError: Cannot read properties of undefined (reading 'name').EPCartProvider,EPBundleProvider,EPVariationPicker,EPProductListProvider, etc. — all 11 already declareprovidesData: true). Looks like the flag was simply missed whenEPProductProviderwas first added.Test plan
EPProductProvider.productis bound to$q.<query>.data(Server Query returning aProduct), pre-fix: page render throwsCannot read properties of undefined (reading 'name')from any binding inside the provider's slot.@elasticpath/plasmic-ep-commerce-elastic-path, the same page renders the product'sname,description,price,imageetc. correctly.EPProductProviderthat use the legacy client-fetch path (productIdprop, noproductprop binding) keep working —providesData: trueis purely additive at the Studio code-gen level and doesn't change runtime behaviour for the component itself.