Websites v4 docs v5.2.5
    Preparing search index...

    Function useSectionVariantControl

    • Admin hook that regenerates the selected section's configuration when the user switches to a variant that defines its own defaults via variantInitialConfig.

      Unlike initialConfig, which only runs once when a section is first added, this runs every time the user changes to a variant that has a generator, overwriting the existing configuration so the section matches the new variant.

      Returns UseSectionVariantControlResult

      const { regenerateForVariant } = useSectionVariantControl();

      const handleChange = (variant: string) => {
      if (regenerateForVariant(variant)) return;
      handleUpdate(variant);
      };