Skip to content

Commit

Permalink
fix(react-devtool): add dependency (#249)
Browse files Browse the repository at this point in the history
* fix: ensure devtool is init before use it

* react-dev-tool dependency
  • Loading branch information
danilowoz authored Dec 9, 2021
1 parent 23ef881 commit d569a6e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sandpack-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"@react-hook/intersection-observer": "^3.1.1",
"codesandbox-import-util-types": "^2.2.3",
"codesandbox-import-utils": "^2.2.3",
"react-devtools-inline": "4.4.0"
"react-devtools-inline": "4.4.0",
"react-is": "^17.0.2"
},
"devDependencies": {
"@babel/core": "^7.12.3",
Expand Down
6 changes: 4 additions & 2 deletions sandpack-react/src/components/ReactDevTools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ export const SandpackReactDevTools = ({
: Object.values(sandpack.clients)[0];
const contentWindow = client?.iframe?.contentWindow;

setDevTools(reactDevtools.current.initialize(contentWindow));
if (reactDevtools.current && contentWindow) {
setDevTools(reactDevtools.current.initialize(contentWindow));
}
}
});

return unsubscribe;
}, [clientId, listen, sandpack.clients]);
}, [reactDevtools, clientId, listen, sandpack.clients]);

useEffect(() => {
sandpack.registerReactDevTools();
Expand Down
2 changes: 1 addition & 1 deletion website/docs/docs/advanced-usage/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default function CustomSandpack() {
<SandpackProvider template="react">
<SandpackLayout>
<SandpackPreview />
<SandpackReactDevTools style={{ width: "50%" }} />
<SandpackReactDevTools style={{ flex: 1 }} />
</SandpackLayout>
</SandpackProvider>
)
Expand Down
2 changes: 1 addition & 1 deletion website/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "next lint"
},
"dependencies": {
"@codesandbox/sandpack-react": "^0.9.1",
"@codesandbox/sandpack-react": "*",
"framer-motion": "^5.3.3",
"next": "12.0.3",
"react": "17.0.2",
Expand Down

0 comments on commit d569a6e

Please sign in to comment.