Codesandbox,io 是否从 REACT 应用程序中删除了 public 目录?为什么没有它它还能工作?

Does Codesandbox,io remove the public directory from REACT apps & Why does it work without it?

我一直在使用 codesandbox.io 并从 codesandbox 做出反应并更新 github。今天,我尝试将它本地拉到我的机器上(并安装它)并对其进行处理,并意识到两件事。

  1. 没用
  2. codesandbox 和 github 中没有 public 目录,所以没有 index.html,但应用程序在 codesandbox 中运行。

所以我有两个问题 1. codesandbox.io 删除了 public 目录还是我? 2. 如果是我,为什么我的应用程序仍然可以在 codesandbox.io

中运行

我的 Codesandbox 在这里 https://codesandbox.io/s/wiki-mogpb?fontsize=14&hidenavigation=1&theme=dark

似乎当您不提供入口点时,codesandbox 会为您添加一个 root 元素,无论如何,删除文件的是您,您应该在独立应用程序中提供一个。

ReactDOM.render(<App />, document.getElementById('root'));

我是傻了!

看起来我将 public 目录移到了我的 CSS 文件夹中,它从那里成功渲染。

这可能就是为什么我把它拉下来时它不起作用的原因。听起来 codesandbox 正在寻找文件,不管它在哪里!