我在我的应用程序中使用样式组件在CodeSandbox中。请参考以下网址 https://lrn6vmq297.sse.codesandbox.io/
每当我进行一些更改时,控制台都会说。
Warning: Prop `className` did not match.
It looks like you've wrapped styled() around your React component (Component), but the className prop is not being passed down to a child. No styles will be rendered unless className is composed within your React component.
并且UI无法按预期呈现。有人知道我为什么遇到这个问题吗?请查看上面的网址。
谢谢
在“codesandbox.io”上,我如何配置“Prettier”以不再更改我的换行符(或者可能完全停用“Priettier”)?
另外,我如何在那里停用 ESLint 中的某个规则(在我的情况下react-hooks/rules-of-hooks是我想关闭) - 在我的 ES201x 项目中似乎忽略了一个新创建的“eslintrc”文件?谢谢。
我正在尝试在codesandbox 中运行json-servernpm。我创建了一个普通项目并添加了对package.json. 我必须运行一个脚本json-server --watch db.json。
Codesandbox 有没有办法运行脚本?
在此代码沙箱中执行以下测试:
import { of } from "rxjs";
import { map } from "rxjs/operators";
const source = of("World");
test("It should fail", () => {
source.subscribe(x => expect(x).toContain("NOTHING"));
});
Run Code Online (Sandbox Code Playgroud)
尽管预期落空,但 Jest 仍将其报告为通过。想法?
以下代码在 codeandbox.io 网站的控制台(该版本使用StrictMode)以及下面的代码段(未使用StrictMode)中打印出相同的时间两次:
const { useState, useEffect } = React;
function useCurrentTime() {
const [timeString, setTimeString] = useState("");
useEffect(() => {
const intervalID = setInterval(() => {
setTimeString(new Date().toLocaleTimeString());
}, 100);
return () => clearInterval(intervalID);
}, []);
return timeString;
}
function App() {
const s = useCurrentTime();
console.log(s);
return <div className="App">{s}</div>;
}
ReactDOM.render(<App />, document.getElementById("root"));Run Code Online (Sandbox Code Playgroud)
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.1/umd/react-dom.development.js"></script>Run Code Online (Sandbox Code Playgroud)
演示:https : //codesandbox.io/s/gallant-bas-3lq5w?file=/ src/ App.js(使用StrictMode)
这是使用生产库的片段;它仍然记录两次:
const { useState, …Run Code Online (Sandbox Code Playgroud)目前,当我尝试在codesandbox.io 上使用基于 URL 的导入时,出现以下错误:
ESModules url 导入仅在实验性 ESModule 预设中受支持。
该预设驻留在哪个配置文件中?
简而言之:执行代码时,我应该得到的典型错误是:“ TypeError:无法读取未定义的属性'setState'”,相反,我收到了一个非常奇怪的跨域错误。
这是错误的屏幕截图:http :
//prntscr.com/iwipnb

错误引发了跨域错误。React不能访问开发中的实际错误对象。有关更多信息,请参见https://reactjs.org/docs/cross-origin-errors.html。
这是我的代码:https : //codesandbox.io/s/4885l37xrw
如何避免FIREFOX中Codesandbox 中的跨域错误?
EDIT1:我知道什么是代码错误(bind(this))。我正在寻找跨域错误 firefox问题。谢谢
我CodeSandbox从 github repo创建了一个。CodeSandbox如果有一些提交推送到 github 存储库,我该如何同步?我看到 Codesandbox 上有一个 github 视图,但它没有显示任何pull操作。
我正在尝试通过导入 github 存储库来使用codesandbox。我无法编辑package.json文件的内容。它说无法在现成的编辑器中进行编辑。如何解决这个错误?
codesandbox ×10
javascript ×4
reactjs ×3
amazon-s3 ×1
eslint ×1
formatting ×1
github ×1
jestjs ×1
node.js ×1
npm-scripts ×1
package.json ×1
prettier ×1
react-hooks ×1
typescript ×1