During the Section overriding process, you can experience issues such as overridden components not appearing or not behaving as expected.
Section override is a feature for customizing and creating new components for your FastStore storefront. However, you may encounter situations where the overridden components don't appear or function as intended.
Below are various troubleshooting checks and instructions you can use to solve your store's issue:
Issue | Troubleshooting instructions |
---|---|
Overrides fail to display in your store. | Check the getOverriddenSection function. |
The custom section is not available in the Headless CMS. | Add the section’s schema in the Headless CMS. |
Overrides are not reflected in the Headless CMS. | Remove default props. |
Styles are not being applied to the component. | Check custom section class names. |
Solution
To understand and correct each error, see the solutions below:
Checking the getOverriddenSection
function
If you encounter an error message mentioning a missing function named getOverriddenSection
, it means you need to import it into your code.
This function is important for displaying product overrides within your store, allowing you to customize specific product page sections. Follow the steps below to import the function to your project:
-
Open the file where you are overriding the section, for example,
ProductDetailsWithCustomButton.tsx
. -
At the top of the file, import the
getOverridenSetion
function:_10import { getOverriddenSection } from '@faststore/core';Here's an example of how to use
getOverriddenSection
in yourProductDetailsWithCustomButton.tsx
file:_10import { ProductDetailsSection, getOverriddenSection } from '@faststore/core'_10_10const ProductDetailsWithCustomButton = getOverriddenSection({_10Section: ProductDetailsSection,_10components: {_10BuyButton: { Component: CustomBuyButton },_10},_10}) -
Run
yarn dev
to sync your changes with your development environment.
Adding the section’s schema in the Headless CMS
If you can't see the changes in the Headless CMS after overriding a prop or a section, this may be due to a missing schema. The Headless CMS will not display your custom section without one.
- Add the schema for the new section to the Headless CMS.
- Replace the native section with your custom one. For detailed instructions, see the guide Syncing components with the Headless CMS.
Removing default props
If the changes you made after overriding a prop are not being reflected or not behaving as expected, this could be due to default prop definitions taking precedence. In this case, default props definitions may override yours when adding the section to the Headless CMS. Props changed via the Headless CMS take precedence over those defined in code through overrides. This can lead to confusion when you try to set a different default value in your code.
Consider removing default values to ensure your overrides work.
- Identify the property you want to modify.
- Check if the property has a default value set in the Admin.
- If the property has a default value set in the Admin, open the
sections.json
file in your store code and find the property you want to change. - Remove the default value from your code.
- Run
yarn cms sync
to sync the changes.
Checking custom section class names
If the style you created is not being applied, make sure that the className
added to the section matches the one declared in the stylesheet. For instance, if you declared className: styles.simpleAlert
in the section, ensure that the corresponding style declaration in the stylesheet is .simpleAlert
.
For more information, see the Override section styles article.