The warning appears when using UIkit to style components in NextJS.
To reproduce:
npx create-next-app {app-name}
cd {app-name} && npm i
pages/index.js
with the snippet below (2nd part)components/layout.js
and add the snippet below (1st part)npm run dev
and go to http://localhost:3000 The app functions normally, but the warnings are really a turn-off
// components/layout.js (1st part) import Head from "next/head"; const Layout = ({ children }) => { return ( <> <Head> {/* UIkit CSS */} <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.5.5/dist/css/uikit.min.css" /> <title>NextJs App</title> {/* UIkit JS */} <script async src="https://cdn.jsdelivr.net/npm/uikit@3.5.5/dist/js/uikit.min.js" /> <script async src="https://cdn.jsdelivr.net/npm/uikit@3.5.5/dist/js/uikit-icons.min.js" /> </Head> {children} </> ); }; export default Layout; // pages/index.js (2nd part) import Layout from "../components/layout"; const Home = () => { return ( <Layout> <div className="uk-child-width-expand@s uk-text-center" data-uk-grid> <div> <div className="uk-card uk-card-default uk-card-body">Item</div> </div> <div> <div className="uk-card uk-card-default uk-card-body">Item</div> </div> <div> <div className="uk-card uk-card-default uk-card-body">Item</div> </div> </div> </Layout> ); }; export default Home;
The error on the console appears as shown in the picture below
The problem seems to have been the way I was loading the scripts.
When I changed the script attribute async
to defer
the Warning was gone and the page was compiled without any warnings
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.