Skip to content

Commit 29abccd

Browse files
Fix useForceUpdate for cases when a callback is not passed
1 parent 88913a5 commit 29abccd

File tree

1 file changed

+4
-1
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Content/Preview

1 file changed

+4
-1
lines changed

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import React, { useState, useCallback, useEffect } from 'react';
33
import _property from 'lodash/property';
4+
import _isFunction from 'lodash/isFunction';
45
import { useOvermind } from 'app/overmind';
56

67
import BasePreview from '@codesandbox/common/lib/components/Preview';
@@ -23,7 +24,9 @@ const useForceUpdate = () => {
2324
);
2425

2526
useEffect(() => {
26-
callback();
27+
if (_isFunction(callback)) {
28+
callback();
29+
}
2730
}, [callback]);
2831

2932
return forceUpdate;

0 commit comments

Comments
 (0)