vtex / faststore

Digital commerce toolkit for frontend developers
https://faststore.dev
MIT License
191 stars 61 forks source link

Issue overwriting component #1857

Closed victors1681 closed 1 year ago

victors1681 commented 1 year ago

Describe the bug I was trying to follow the instructions about how to overwrite components and if we don't pass down all the props we run into the following issue.

https://www.faststore.dev/docs/building-sections/overriding-a-native-component

import { SectionOverride } from '@faststore/core/src/typings/overrides'
import { Price as CustomPrice } from '../Price'

const SECTION = 'ProductDetails' as const

const overrides: SectionOverride[type of SECTION] = {
  name: SECTION,
  components: {
    Price: { Component: CustomPrice },
  },
}

export default overrides

Expected behavior After pass down only one or multiples it should work without list all the props at once.

Current behavior We we use the example in the documentation we get the following

Screenshot 2023-06-23 at 4 08 06 PM

Possible Solution Initialize the props with the default values node_modules/@faststore/core/src/components/sections/ProductDetails/Overrides.tsx

const productDetailsPropsCustomization = {
  ProductTitle: { props: {} },
  DiscountBadge: { props: {} },
  BuyButton: { props: {} },
  Icon: { props: {} },
  Price: { props: {} },
  QuantitySelector: { props: {} },
  SkuSelector: { props: {} },
  ShippingSimulation: { props: {} },
  ImageGallery: { props: {} },
  ImageZoom: { props: {} },
  __experimentalImageGalleryImage: { props: {} },
  __experimentalImageGallery: { props: {} },
  __experimentalShippingSimulation: { props: {} },
} as any
icazevedo commented 1 year ago

Thanks for reporting the issue, @victors1681! Which version of @faststore/core are you using?

victors1681 commented 1 year ago

@icazevedo I'm using "@faststore/core": "2.1.5", and I also tried with the latest 2.1.28 same thing

icazevedo commented 1 year ago

@victors1681 it's weird that you had this issue when using the latest version last week. This week we've updated the Section Override API with types and also made a few changes to the API itself. Could you update your @faststore/core version to the latest one and follow the docs again? They've been updated as well, with more updates to come.