@carbon/ibm-products
Version:
Carbon for IBM Products
34 lines (32 loc) • 824 B
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { useEffect } from "react";
//#region src/global/js/hooks/useRetrieveFormTitles.js
/**
* Copyright IBM Corp. 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const useRetrieveFormTitles = ({ formContext, formNumber, title }) => {
useEffect(() => {
if (formContext) formContext.setFormTitles((prev) => {
if (prev[formNumber] !== title) {
const clone = [...prev];
clone[formNumber] = title;
return clone;
}
return prev;
});
}, [
title,
formContext,
formNumber
]);
};
//#endregion
export { useRetrieveFormTitles };