React-router showing blank page

I’m new to React and currently working on a project in a tutorial. My app has been working fine with static routes, however, as soon as I introduce react router in my app, I get only blank page without any error. I have been searching for last two days, and tried all given solution such as:

  1. downgrade react router dom to v5.
  2. using exact keyword
  3. switched between component and element keyword
  4. Using Routes and without using Routes.

However, none of the solutions seem to work. I have a doubt that it is related to some other package dependency may be, but not sure which package to touch. Following is my package.json configuration:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> "name": "merstart",
"version": "1.0.0",
"description": "MERN practice",
"main": "index.js",
"scripts": {
"start": "nodemon -w server server/server.js",
"compile": "webpack",
"watch": "webpack-dev-server --hot --no-client-overlay-runtime-errors",
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.20.2",
"express": "^4.19.2",
"mongodb": "^6.8.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.3.0",
"babel-polyfill": "^6.26.0",
"nodemon": "^3.1.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.0",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^7.3.0",
"webpack-dev-server": "^5.0.4",
"webpack-hot-middleware": "^2.26.1",
"whatwg-fetch": "^3.6.20"
}
}
</code>
<code> "name": "merstart", "version": "1.0.0", "description": "MERN practice", "main": "index.js", "scripts": { "start": "nodemon -w server server/server.js", "compile": "webpack", "watch": "webpack-dev-server --hot --no-client-overlay-runtime-errors", "test": "echo "Error: no test specified" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "body-parser": "^1.20.2", "express": "^4.19.2", "mongodb": "^6.8.0" }, "devDependencies": { "@babel/cli": "^7.0.0", "@babel/preset-env": "^7.0.0", "@babel/preset-react": "^7.0.0", "babel-loader": "^8.3.0", "babel-polyfill": "^6.26.0", "nodemon": "^3.1.4", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router-dom": "^6.26.0", "webpack": "^5.93.0", "webpack-cli": "^5.1.4", "webpack-dev-middleware": "^7.3.0", "webpack-dev-server": "^5.0.4", "webpack-hot-middleware": "^2.26.1", "whatwg-fetch": "^3.6.20" } } </code>
  "name": "merstart",
  "version": "1.0.0",
  "description": "MERN practice",
  "main": "index.js",
  "scripts": {
    "start": "nodemon -w server server/server.js",
    "compile": "webpack",
    "watch": "webpack-dev-server --hot --no-client-overlay-runtime-errors",
    "test": "echo "Error: no test specified" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.20.2",
    "express": "^4.19.2",
    "mongodb": "^6.8.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.3.0",
    "babel-polyfill": "^6.26.0",
    "nodemon": "^3.1.4",
    "react": "^18.3.1",
    "react-dom": "^18.3.1",
    "react-router-dom": "^6.26.0",
    "webpack": "^5.93.0",
    "webpack-cli": "^5.1.4",
    "webpack-dev-middleware": "^7.3.0",
    "webpack-dev-server": "^5.0.4",
    "webpack-hot-middleware": "^2.26.1",
    "whatwg-fetch": "^3.6.20"
  }
}

My main app code is as following:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router, Routes,Route} from 'react-router-dom';
import IssueEdit from './IssueEdit.jsx';
//import IssueAdd from './IssueAdd.jsx';
const contentNode = document.getElementById('contents');
const noMatch = ()=> <p>Page not found.</p>
const RoutedApp = ()=> {
console.log("Reached routed app");
<Router>
<Routes>
<Route path="/" action={()=>{console.log("action")}} loader={()=>{console.log("Loader")}} element={<IssueList />} />
<Route path="/issueEdit" element={<IssueEdit />} />
<Route path="*" element={<noMatch />} />
</Routes>
</Router>
console.log("Reached end of router");
};
ReactDOM.render(<RoutedApp />,contentNode);
if(module.hot){
module.hot.accept();
}
</code>
<code>import React from 'react'; import ReactDOM from 'react-dom'; import {BrowserRouter as Router, Routes,Route} from 'react-router-dom'; import IssueEdit from './IssueEdit.jsx'; //import IssueAdd from './IssueAdd.jsx'; const contentNode = document.getElementById('contents'); const noMatch = ()=> <p>Page not found.</p> const RoutedApp = ()=> { console.log("Reached routed app"); <Router> <Routes> <Route path="/" action={()=>{console.log("action")}} loader={()=>{console.log("Loader")}} element={<IssueList />} /> <Route path="/issueEdit" element={<IssueEdit />} /> <Route path="*" element={<noMatch />} /> </Routes> </Router> console.log("Reached end of router"); }; ReactDOM.render(<RoutedApp />,contentNode); if(module.hot){ module.hot.accept(); } </code>
import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter as Router, Routes,Route} from 'react-router-dom';
import IssueEdit from './IssueEdit.jsx';



//import IssueAdd from './IssueAdd.jsx';

const contentNode = document.getElementById('contents');

const noMatch = ()=> <p>Page not found.</p>

const RoutedApp = ()=> {
    console.log("Reached routed app");
    <Router>
    <Routes>
        <Route path="/" action={()=>{console.log("action")}} loader={()=>{console.log("Loader")}} element={<IssueList />} />
        <Route path="/issueEdit" element={<IssueEdit />} />
        <Route path="*" element={<noMatch />} />
    </Routes>
    </Router>
    console.log("Reached end of router");
};

ReactDOM.render(<RoutedApp />,contentNode);

if(module.hot){
    module.hot.accept();
}

Both the console logs for RoutedApp start and end are printed in console, but but console in action of first Route is not printed. Note that if I directly render my IssueList.jsx, it works fine, but when I try with react router it fails.

There are no errors to show. Can anyone guide please.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật