From f86c609ff147348e15c1a51bbd64f79b4693bdcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B4mulo=20Penido?= Date: Tue, 26 Nov 2024 19:41:04 -0300 Subject: [PATCH] fix: editor flicker after creating xblock (#1531) --- src/editors/hooks.test.jsx | 12 ++++++++++-- src/editors/hooks.ts | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/editors/hooks.test.jsx b/src/editors/hooks.test.jsx index 4a247a802c..103577a98a 100644 --- a/src/editors/hooks.test.jsx +++ b/src/editors/hooks.test.jsx @@ -50,11 +50,19 @@ describe('hooks', () => { describe('initializeApp', () => { test('calls provided function with provided data as args when useEffect is called', () => { const dispatch = jest.fn(); - const fakeData = { some: 'data' }; + const fakeData = { + blockId: 'blockId', + studioEndpointUrl: 'studioEndpointUrl', + learningContextId: 'learningContextId', + }; hooks.initializeApp({ dispatch, data: fakeData }); expect(dispatch).not.toHaveBeenCalledWith(fakeData); const [cb, prereqs] = useEffect.mock.calls[0]; - expect(prereqs).toStrictEqual([fakeData]); + expect(prereqs).toStrictEqual([ + fakeData.blockId, + fakeData.studioEndpointUrl, + fakeData.learningContextId, + ]); cb(); expect(dispatch).toHaveBeenCalledWith(thunkActions.app.initialize(fakeData)); }); diff --git a/src/editors/hooks.ts b/src/editors/hooks.ts index d2a7403d87..c32d608008 100644 --- a/src/editors/hooks.ts +++ b/src/editors/hooks.ts @@ -9,7 +9,7 @@ import { RequestKeys } from './data/constants/requests'; // eslint-disable-next-line react-hooks/rules-of-hooks export const initializeApp = ({ dispatch, data }) => useEffect( () => dispatch(thunkActions.app.initialize(data)), - [data], + [data?.blockId, data?.studioEndpointUrl, data?.learningContextId], ); export const navigateTo = (destination: string | URL) => {