简体   繁体   English

Codesandbox,io 是否从 REACT 应用程序中删除公共目录?为什么没有它它可以工作?

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

I have been working with codesandbox.io and react and updating github from codesandbox.我一直在使用codesandbox.io 并从codesandbox 做出反应和更新github。 Today I tried to pull it down locally onto my machine (and install it) and work on it and realized two things.今天我试图将它本地拉到我的机器上(并安装它)并在它上面工作并实现了两件事。

  1. It didn't work它没有用
  2. There was no public directory in codesandbox and github, so no index.html but the app works in codesandbox. Codesandbox 和 github 中没有公共目录,所以没有 index.html 但该应用程序可以在代码沙盒中运行。

So I have 2 questions 1. Does codesandbox.io remove the public directory or was it me?所以我有 2 个问题 1. codesandbox.io 是删除公共目录还是我? 2. If it was me why does my app still work in codesandbox.io 2.如果是我,为什么我的应用程序仍然在codeandbox中运行。io

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

It seems when you not providing an entry point, codesandbox adding a root element for you, in any case the one that removed the file is you and you should provide one in your standalone application.似乎当您不提供入口点时,codesandbox 会为您添加root元素,无论如何删除文件的是您,您应该在独立应用程序中提供一个。

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

在此处输入图像描述

I was being stupid!我是愚蠢的!

Looks like I moved the public directory into my CSS folder and it was rendering from there successfully.看起来我将公共目录移到了我的 CSS 文件夹中,并且从那里成功渲染。

Thats probably why its not working when i pull it down.这可能就是为什么当我把它拉下来时它不工作的原因。 Sounds like codesandbox is finding the file regardless of where it is!听起来codesandbox正在寻找文件,无论它在哪里!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM