سلام
کدی که نوشتم خطای زیر را میده. این مربوط به reat 18 یا ورژن پایین webpack نیست؟
0] Failed to compile.
[0]
[0] Module not found: Error: Can't resolve 'url' in 'C:\\Users\\user\\Desktop\\react\\54\\simple-blog\\node_modules\\hookrouter\\dist'
[0] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
[0] This is no longer the case. Verify if you need this module and configure a polyfill for it.
[0]
[0] If you want to include a polyfill, you need to:
[0] - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
[0] - install 'url'
[0] If you don't want to include a polyfill, you can use an empty module like this:
[0] resolve.fallback: { "url": false }
[0] ERROR in ./node_modules/hookrouter/dist/router.js 76:14-28
[0] Module not found: Error: Can't resolve 'url' in 'C:\\Users\\user\\Desktop\\react\\54\\simple-blog\\node_modules\\hookrouter\\dist'
[0]
[0] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
[0] This is no longer the case. Verify if you need this module and configure a polyfill for it.
[0]
[0] If you want to include a polyfill, you need to:
[0] - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
[0] - install 'url'
[0] If you don't want to include a polyfill, you can use an empty module like this:
[0] resolve.fallback: { "url": false }
[0]
[0] webpack compiled with 1 error
این هم کلاس App که مطابق فیلم نوشتم:
import { useRoutes } from "hookrouter";
import BlogPage from "./pages/BlogPage";
import HomePage from "./pages/HomePage";
import PostPage from "./pages/PostPage";
import NotFoundPage from "./pages/NotFoundPage";
const routes={
'/':()=><HomePage />,
'/blog':()=><BlogPage />,
'/post/:id':({id})=><PostPage id={id} />
}
function App() {
const match=useRoutes(routes)
return match||<NotFoundPage />
}
export default App;