javascript - Warning: Received `false` for a non-boolean attribute `className`. If you want to write it to the DOM, pass a strin
- c - Solaris 10 make Error code 1 Fatal Error when trying to build python 2.7.16 - Stack Overflow 推荐度:
- javascript - How to dismiss a phonegap notification programmatically - Stack Overflow 推荐度:
- javascript - Get the JSON objects that are not present in another array - Stack Overflow 推荐度:
- javascript - VS 2015 Angular 2 import modules cannot be resolved - Stack Overflow 推荐度:
- javascript - Type 'undefined' is not assignable to type 'menuItemProps[]' - Stack Overflow 推荐度:
- 相关推荐
I know many people have already questioned the same question but none of their answer worked for me anyways...
Im having this error:
If you want to write it to the DOM, pass a string instead: className="false" or className={value.toString()}.
If you used to conditionally omit it with className={condition && value}, pass className={condition ? value : undefined} instead.
at a
at Link (webpack-internal:///./node_modules/next/dist/client/link.js:79:19)
at li
at SellerSidebarData (webpack-internal:///./ponents/sellerp/SSData.js:17:3)
at ul
at div
at div
at SellerSidebar (webpack-internal:///./ponents/sellerp/SellerSidebar.js:31:20)
at div
at SellerLayout (webpack-internal:///./ponents/sellerp/SellerLayout.js:22:3)
at MyApp (webpack-internal:///./pages/_app.js:55:3)
at AppContainer (/node_modules/next/dist/next-server/server/render.js:27:952)
And this is my code :
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
const SellerSidebarData = ({ classPath, path, icon, title }) => {
const router = useRouter();
return (
<li>
<Link href={path}>
<a
className={
router.pathname == classPath &&
'wave-effect waves-effect waves-button active'
}
>
<i aria-hidden className={`width18 textCenter ${icon}`}></i>
{title}
</a>
</Link>
</li>
);
};
export default SellerSidebarData;
Btw, i know that there is error on three files but if you could just answer the code i gave i most possibly answer the other files... Thank you so much in advance!!!
I know many people have already questioned the same question but none of their answer worked for me anyways...
Im having this error:
If you want to write it to the DOM, pass a string instead: className="false" or className={value.toString()}.
If you used to conditionally omit it with className={condition && value}, pass className={condition ? value : undefined} instead.
at a
at Link (webpack-internal:///./node_modules/next/dist/client/link.js:79:19)
at li
at SellerSidebarData (webpack-internal:///./ponents/sellerp/SSData.js:17:3)
at ul
at div
at div
at SellerSidebar (webpack-internal:///./ponents/sellerp/SellerSidebar.js:31:20)
at div
at SellerLayout (webpack-internal:///./ponents/sellerp/SellerLayout.js:22:3)
at MyApp (webpack-internal:///./pages/_app.js:55:3)
at AppContainer (/node_modules/next/dist/next-server/server/render.js:27:952)
And this is my code :
import React from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
const SellerSidebarData = ({ classPath, path, icon, title }) => {
const router = useRouter();
return (
<li>
<Link href={path}>
<a
className={
router.pathname == classPath &&
'wave-effect waves-effect waves-button active'
}
>
<i aria-hidden className={`width18 textCenter ${icon}`}></i>
{title}
</a>
</Link>
</li>
);
};
export default SellerSidebarData;
Btw, i know that there is error on three files but if you could just answer the code i gave i most possibly answer the other files... Thank you so much in advance!!!
Share Improve this question asked Jul 13, 2021 at 6:20 user13423237user13423237 1-
1
If you used to conditionally omit it with
className={condition && value}
, passclassName={condition ? value : undefined}
instead. – PsyGik Commented Jul 13, 2021 at 6:34
2 Answers
Reset to default 4You are leaking a boolean to the DOM when router.pathname == classPath
evaluates false. Use a ternary to return an empty string classname for the falsey path.
<Link href={path}>
<a
className={
router.pathname === classPath ?
'wave-effect waves-effect waves-button active' : ''
}
>
<i aria-hidden className={`width18 textCenter ${icon}`}></i>
{title}
</a>
</Link>
<a className={
router.pathname == classPath ?
'wave-effect waves-effect waves-button active':''
}
>
- 微软服软涉足iOS、安卓背后:以开发者为重
- 苹果WWDC2014:iOS 8新功能都有哪些?
- 微软推绿色IT挑战新网站促进IT节能环保
- 奇虎起诉腾讯:“中国互联网反垄断第一案”今日开庭
- google tag manager - GTM custom template - not able to trigger callback from script - Stack Overflow
- javascript - Read text file and put result to innerHTML? - Stack Overflow
- open source - Langgraph State not being passed properly with Ollama - Stack Overflow
- flutter - having issue about qr code scanner that can scan almost everything - Stack Overflow
- How to implement GPU memory recycling in CUDA C++ for data streaming in TensorFlow? - Stack Overflow
- reactjs - How to change output directory of wxt extension framework - Stack Overflow
- python - Ipywidgets : How to get the list of comm opened in a jupyter notebook? - Stack Overflow
- How to work with output of tsdisplay (capturemodify plots produced by it) in R - Stack Overflow
- c - What happens if you call free() on non allocated memory returned by a function - Stack Overflow
- window - Strawberry Perl doesn't include Win32::shortcut? - Stack Overflow
- c++ - Member of struct constructed twice in custom constructor? - Stack Overflow
- GHC unable to find mingwinclude directory on Windows - Stack Overflow
- ios - Persist overlay view in the detail side of NavigationSplitView - Stack Overflow