e52ae97233
Co-authored-by: asiaznik <artur@vegaprotocol.io> Co-authored-by: Ben <ben@vega.xyz>
19 lines
493 B
TypeScript
19 lines
493 B
TypeScript
import { useEffect, useMemo } from 'react';
|
|
import { titlefy } from '@vegaprotocol/utils';
|
|
import { usePageTitleStore } from '../../stores';
|
|
|
|
export const usePageTitle = (title: string | string[]) => {
|
|
const { updateTitle } = usePageTitleStore((store) => ({
|
|
updateTitle: store.updateTitle,
|
|
}));
|
|
|
|
const memotitle = useMemo(
|
|
() => titlefy(Array.isArray(title) ? title : [title]),
|
|
[title]
|
|
);
|
|
|
|
useEffect(() => {
|
|
updateTitle(memotitle);
|
|
}, [updateTitle, memotitle]);
|
|
};
|