gpt4 book ai didi

reactjs - 忽略错误 className did not match Server and Client in Gatsby

转载 作者:行者123 更新时间:2023-12-05 06:05:17 24 4
gpt4 key购买 nike

我正在使用 css 框架并像这样放置 cdns

//public <head> tag
<Helmet>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.6.15/dist/css/uikit.min.css" />
<script src="https://cdn.jsdelivr.net/npm/uikit@3.6.15/dist/js/uikit.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/uikit@3.6.15/dist/js/uikit-icons.min.js"></script>
</Helmet>

组件内部的例子

//Layout menu
<nav className="uk-navbar-container" data-uk-navbar="">
<div className="uk-navbar-center">
<ul className="uk-navbar-nav">
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/request">Request</Link></li>
</ul>
</div>
</nav>
...

例如,我收到错误

Warning: Prop `className` did not match. Server: "uk-navbar-container uk-navbar" Client: "uk-navbar-container"

UIkit JS 会在页面加载时调整 class (className),我想保留它用于动画内容。那我试过了

// just add "uk-navbar" fixed the errors
<nav className="uk-navbar-container uk-navbar" data-uk-navbar="">
<div className="uk-navbar-center">
<ul className="uk-navbar-nav">
<li><Link to="/">Home</Link></li>
<li><Link to="/about">About</Link></li>
<li><Link to="/request">Request</Link></li>
</ul>
</div>
</nav>
...

但实际上要查找的错误太多了

如何关闭(忽略)Gatsby 中的错误(警告)?

最佳答案

默认情况下,Gatsby 带有默认的 ESLint 配置。从docs可以看出:

Gatsby ships with a built-in ESLint setup. For most users, ourbuilt-in ESLint setup is all you need. If you know however that you’dlike to customize your ESLint config e.g. your company has their owncustom ESLint setup, this shows how this can be done

要禁用 ESLint,只需在项目的根目录中创建一个空的 .eslintrc 文件即可。

关于reactjs - 忽略错误 className did not match Server and Client in Gatsby,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66057434/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com