sandpack icon indicating copy to clipboard operation
sandpack copied to clipboard

Editor hangs when useEffect has no dependency specifed

Open kircod opened this issue 1 year ago • 0 comments

Bug report

Packages affected

  • [ ] sandpack-client
  • [x] sandpack-react

Description of the problem

Unable to type in editor when useEffect has no dependency specified.
Code used in the editor.

import React, { useEffect, useState } from "react";

const App = () => {
  const [count, setCount] = useState(0);

  useEffect(() => {
    setCount((count) => count + 1);
  });

  return (
    <div>Test</div>
  )
};

export default App;

What were you doing when the problem occurred?

Trying to type in the sandpack editor.

What steps can we take to reproduce the problem?

Code used for setup.

import React from "react";
import { Sandpack } from "@codesandbox/sandpack-react";

const App = () => {
  const files = {}
  
  return (
    <Sandpack
      files={files} 
      theme="light" 
      template="react"
      options={{
        showConsoleButton: true,
        showInlineErrors: true,
        showNavigator: true,
        showLineNumbers: true,
        showTabs: true,
      }}
    />
  )  
}

export default App;

Attached screen recording

https://github.com/codesandbox/sandpack/assets/60211909/97fe1679-e708-48f3-8df0-2cd25e199ba2

Link to sandbox: link (optional)

Your Environment

Software Name/Version
Sandpack-client version
Sandpack-react version 2.10.0
Browser Chrome
Operating System Mac

kircod avatar Dec 09 '23 11:12 kircod