Skip to content

Commit

Permalink
fix: editor flicker after creating xblock (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido authored Nov 26, 2024
1 parent ec3f78f commit f86c609
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/editors/hooks.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
});
Expand Down
2 changes: 1 addition & 1 deletion src/editors/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit f86c609

Please sign in to comment.