From 2abc9fa0e8afb7d4e23a317d21cb5f606de0cc34 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Tue, 18 May 2021 08:43:41 -0500 Subject: [PATCH] Merge pull request #4042 from overleaf/as-prevent-set-title Prevent setting title on every render GitOrigin-RevId: d9e5ad7d7a23099f153686f538ab3e733b3b7b07 --- .../web/frontend/js/shared/context/editor-context.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/web/frontend/js/shared/context/editor-context.js b/services/web/frontend/js/shared/context/editor-context.js index fb79229ccc..c6b9ece81a 100644 --- a/services/web/frontend/js/shared/context/editor-context.js +++ b/services/web/frontend/js/shared/context/editor-context.js @@ -1,4 +1,4 @@ -import React, { createContext, useCallback, useContext } from 'react' +import React, { createContext, useCallback, useContext, useEffect } from 'react' import PropTypes from 'prop-types' import useScopeValue from './util/scope-value-hook' import { useApplicationContext } from './application-context' @@ -98,9 +98,11 @@ export function EditorProvider({ children, ide, settings }) { ) const { setTitle } = useBrowserWindow() - setTitle( - `${projectName ? projectName + ' - ' : ''}Online LaTeX Editor ${appName}` - ) + useEffect(() => { + setTitle( + `${projectName ? projectName + ' - ' : ''}Online LaTeX Editor ${appName}` + ) + }, [appName, projectName, setTitle]) const editorContextValue = { cobranding,