Skip to content

Commit 987814f

Browse files
authored
fix(use-files): watch prop keys changes (#776)
1 parent 505b060 commit 987814f

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

sandpack-react/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
"dequal": "^2.0.2",
5555
"lz-string": "^1.4.4",
5656
"react-devtools-inline": "4.4.0",
57-
"react-is": "^17.0.2",
58-
"use-deep-compare-effect": "1.8.1"
57+
"react-is": "^17.0.2"
5958
},
6059
"devDependencies": {
6160
"@babel/core": "^7.12.3",

sandpack-react/src/contexts/utils/useFiles.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { SandpackBundlerFiles } from "@codesandbox/sandpack-client";
22
import { normalizePath } from "@codesandbox/sandpack-client";
3-
import { useState } from "react";
4-
import useDeepCompareEffect from "use-deep-compare-effect";
3+
import { useEffect, useState } from "react";
54

65
import type {
76
SandboxEnvironment,
@@ -57,9 +56,9 @@ export const useFiles: UseFiles = (props) => {
5756

5857
const [state, setState] = useState<FilesState>(originalStateFromProps);
5958

60-
useDeepCompareEffect(() => {
59+
useEffect(() => {
6160
setState(getSandpackStateFromProps(props));
62-
}, [props]);
61+
}, [props.files, props.customSetup, props.template]);
6362

6463
const updateFile = (
6564
pathOrFiles: string | SandpackFiles,

yarn.lock

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18779,14 +18779,6 @@ use-clipboard-copy@^0.2.0:
1877918779
dependencies:
1878018780
clipboard-copy "^3.0.0"
1878118781

18782-
18783-
version "1.8.1"
18784-
resolved "https://registry.yarnpkg.com/use-deep-compare-effect/-/use-deep-compare-effect-1.8.1.tgz#ef0ce3b3271edb801da1ec23bf0754ef4189d0c6"
18785-
integrity sha512-kbeNVZ9Zkc0RFGpfMN3MNfaKNvcLNyxOAAd9O4CBZ+kCBXXscn9s/4I+8ytUER4RDpEYs5+O6Rs4PqiZ+rHr5Q==
18786-
dependencies:
18787-
"@babel/runtime" "^7.12.5"
18788-
dequal "^2.0.2"
18789-
1879018782
1879118783
version "1.2.0"
1879218784
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a"

0 commit comments

Comments
 (0)