Skip to content

Add React Router support with 404 page#59

Closed
coderpurohit wants to merge 1 commit into
AOSSIE-Org:mainfrom
coderpurohit:add-routing-404-page
Closed

Add React Router support with 404 page#59
coderpurohit wants to merge 1 commit into
AOSSIE-Org:mainfrom
coderpurohit:add-routing-404-page

Conversation

@coderpurohit
Copy link
Copy Markdown

@coderpurohit coderpurohit commented May 13, 2026

Addressed Issues

Fixes #40

Summary

Implemented basic client-side routing using react-router-dom.

Changes made

  • Wrapped app with BrowserRouter
  • Added route handling in App.tsx
  • Added dedicated 404 page for unknown routes
  • Updated layout styling

#Validation

  • npm run build
  • npm run lint

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Walkthrough

This PR introduces client-side routing using React Router. It adds react-router-dom as a dependency, wraps the application with BrowserRouter at the entry point, defines Home and NotFoundPage components with explicit route mapping, and updates CSS with global resets and flexbox-based layout styles for routing containers.

Changes

Client-Side Routing Implementation

Layer / File(s) Summary
Dependency & Bootstrap Setup
package.json, src/main.tsx
Added react-router-dom dependency and imported BrowserRouter to wrap the React app at render time, establishing the routing context for the entire application.
Routing Components & Routes Configuration
src/App.tsx
Implemented Home and NotFoundPage internal components and configured Routes to match the root path to Home and catch-all routes to NotFoundPage with a back-to-home link.
Global & Container Styling
src/index.css, src/App.css
Applied a global CSS reset via universal selector with explicit body typography and background colors, and updated root and container styles to use full-width flexbox layouts centered both horizontally and vertically.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Typescript Lang

Suggested reviewers

  • Zahnentferner

Poem

🐰 Routes now lead where pages once stood still,
A Router's magic bends to dev's will,
Home and NotFound dance in flexbox grace,
Navigation flows through browser's space! 🌐

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: adding React Router support with a 404 page, which is demonstrated across multiple files (package.json dependency, App.tsx routing setup, main.tsx BrowserRouter wrapper, and new NotFoundPage component).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/App.css`:
- Around line 5-16: The .home-container, .notfound-container rule contains
unnecessary blank lines before declarations which triggers stylelint's
declaration-empty-line-before; remove the empty lines so declarations
(min-height, display, flex-direction, justify-content, align-items, text-align)
are directly one-per-line without preceding blank lines and preserve existing
ordering and indentation in the .home-container, .notfound-container block to
satisfy the CSS style guide.
- Line 7: Replace the static viewport height declaration in App.css (the
min-height: 100vh property) with a dynamic viewport fallback pattern to avoid
mobile clipping: keep the legacy fallback first (min-height: 100vh) and then
override it with the dynamic unit (min-height: 100dvh) so modern browsers use
100dvh while older ones fall back to 100vh.
- Around line 18-31: The global selectors h1, a, and a:hover are leaking styles;
scope them to route/container classes instead (e.g., use a route wrapper class
like .route-container or specific page classes) so headings and links in other
views aren't affected; update the rules that target h1, a, and a:hover to target
.route-container h1, .route-container a, and .route-container a:hover (or the
specific route/page class names you use) and ensure class names follow the
project's naming conventions for CSS files.

In `@src/App.tsx`:
- Line 5: Replace hardcoded user-facing strings in the App component with i18n
lookups: import and use the translation hook (e.g., useTranslation or t) in the
App function and replace occurrences like "<h1>Hello, OrgExplorer!</h1>" and the
strings on lines 12–13 with t('key') calls (define keys such as "app.title" and
the other two keys in your locale resource files). Ensure you add the new keys
to the appropriate locale JSON and keep the original text as the default value
in the resource file.
- Line 1: Replace native anchors with React Router's Link: add import { Link }
from 'react-router-dom' and change <a href="/"> usages to <Link to="/"> to avoid
full page reloads (search for the anchor in App.tsx). Externalize the hardcoded
UI strings "Hello, OrgExplorer!", "404 - Page Not Found", and "Go Back Home" to
the i18n resource files and replace usages with the project i18n lookup (e.g.,
useTranslation hook or existing t function) so the component reads labels via
t('...') instead of string literals; update imports to include the i18n hook
(useTranslation or project equivalent) and use the same translation keys in the
resource files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b1b729e5-cfef-4080-a8ba-a24e8a8363cb

📥 Commits

Reviewing files that changed from the base of the PR and between cc79e19 and be44492.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • package.json
  • src/App.css
  • src/App.tsx
  • src/index.css
  • src/main.tsx

Comment thread src/App.css
Comment on lines +5 to +16
.home-container,
.notfound-container {
min-height: 100vh;

display: flex;
flex-direction: column;

justify-content: center;
align-items: center;

text-align: center;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix stylelint violations in the route container block.

Line 9, Line 12, and Line 15 have empty lines before declarations (declaration-empty-line-before), which will fail stylelint.

Proposed fix
 .home-container,
 .notfound-container {
   min-height: 100vh;
-
   display: flex;
   flex-direction: column;
-
   justify-content: center;
   align-items: center;
-
   text-align: center;
 }

As per coding guidelines, "**/*.css: Review the CSS code against the google css style guide... and best practices associated with CSS."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.home-container,
.notfound-container {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.home-container,
.notfound-container {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
🧰 Tools
🪛 Stylelint (17.11.0)

[error] 9-9: Expected no empty line before declaration (declaration-empty-line-before)

(declaration-empty-line-before)


[error] 12-12: Expected no empty line before declaration (declaration-empty-line-before)

(declaration-empty-line-before)


[error] 15-15: Expected no empty line before declaration (declaration-empty-line-before)

(declaration-empty-line-before)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.css` around lines 5 - 16, The .home-container, .notfound-container
rule contains unnecessary blank lines before declarations which triggers
stylelint's declaration-empty-line-before; remove the empty lines so
declarations (min-height, display, flex-direction, justify-content, align-items,
text-align) are directly one-per-line without preceding blank lines and preserve
existing ordering and indentation in the .home-container, .notfound-container
block to satisfy the CSS style guide.

Comment thread src/App.css

.home-container,
.notfound-container {
min-height: 100vh;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use dynamic viewport height to avoid mobile clipping/jump.

min-height: 100vh can produce layout jumps on mobile browser UI changes. Add 100dvh with fallback.

Proposed fix
 .home-container,
 .notfound-container {
-  min-height: 100vh;
+  min-height: 100vh;
+  min-height: 100dvh;

As per coding guidelines, "**/*.css: ...adhere to best practices recommended by lighthouse or similar tools for performance."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
min-height: 100vh;
.home-container,
.notfound-container {
min-height: 100vh;
min-height: 100dvh;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.css` at line 7, Replace the static viewport height declaration in
App.css (the min-height: 100vh property) with a dynamic viewport fallback
pattern to avoid mobile clipping: keep the legacy fallback first (min-height:
100vh) and then override it with the dynamic unit (min-height: 100dvh) so modern
browsers use 100dvh while older ones fall back to 100vh.

Comment thread src/App.css
Comment on lines +18 to 31
h1 {
font-size: 4rem;
margin-bottom: 20px;
}

a {
color: #4ea1ff;
text-decoration: none;
font-size: 18px;
}

a:hover {
text-decoration: underline;
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Scope typography/link rules to route containers to prevent global style bleed.

These global selectors can unintentionally restyle headings/links in unrelated views.

Proposed refactor
-h1 {
+.home-container h1,
+.notfound-container h1 {
   font-size: 4rem;
   margin-bottom: 20px;
 }
 
-a {
+.home-container a,
+.notfound-container a {
   color: `#4ea1ff`;
   text-decoration: none;
   font-size: 18px;
 }
 
-a:hover {
+.home-container a:hover,
+.notfound-container a:hover {
   text-decoration: underline;
 }

As per coding guidelines, "**/*.css: ...adhere to similar naming conventions for classes, ids."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.css` around lines 18 - 31, The global selectors h1, a, and a:hover
are leaking styles; scope them to route/container classes instead (e.g., use a
route wrapper class like .route-container or specific page classes) so headings
and links in other views aren't affected; update the rules that target h1, a,
and a:hover to target .route-container h1, .route-container a, and
.route-container a:hover (or the specific route/page class names you use) and
ensure class names follow the project's naming conventions for CSS files.

Comment thread src/App.tsx
@@ -1,12 +1,28 @@
import './App.css'
import { Routes, Route } from 'react-router-dom'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

cat -n src/App.tsx

Repository: AOSSIE-Org/OrgExplorer

Length of output: 694


Use React Router Link instead of native anchor, and externalize hardcoded UI strings.

Using <a href="/"> triggers a full page reload in this React Router SPA. Additionally, user-visible strings ("Hello, OrgExplorer!", "404 - Page Not Found", "Go Back Home") are hardcoded and should be externalized to i18n resource files per coding guidelines.

Suggested fix
-import { Routes, Route } from 'react-router-dom'
+import { Routes, Route, Link } from 'react-router-dom'
@@
-      <a href="/">Go Back Home</a>
+      <Link to="/">Go Back Home</Link>

Also externalize hardcoded strings to i18n resources.

Also applies to: 13-13 (and strings on lines 5, 12)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.tsx` at line 1, Replace native anchors with React Router's Link: add
import { Link } from 'react-router-dom' and change <a href="/"> usages to <Link
to="/"> to avoid full page reloads (search for the anchor in App.tsx).
Externalize the hardcoded UI strings "Hello, OrgExplorer!", "404 - Page Not
Found", and "Go Back Home" to the i18n resource files and replace usages with
the project i18n lookup (e.g., useTranslation hook or existing t function) so
the component reads labels via t('...') instead of string literals; update
imports to include the i18n hook (useTranslation or project equivalent) and use
the same translation keys in the resource files.

Comment thread src/App.tsx
function App() {
function Home() {
return (
<h1>Hello, OrgExplorer!</h1>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Externalize user-facing strings to i18n resources.

These hardcoded strings should come from localization resources to meet the repo’s i18n requirement.

As per coding guidelines, "User-visible strings should be externalized to resource files (i18n)".

Also applies to: 12-13

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/App.tsx` at line 5, Replace hardcoded user-facing strings in the App
component with i18n lookups: import and use the translation hook (e.g.,
useTranslation or t) in the App function and replace occurrences like
"<h1>Hello, OrgExplorer!</h1>" and the strings on lines 12–13 with t('key')
calls (define keys such as "app.title" and the other two keys in your locale
resource files). Ensure you add the new keys to the appropriate locale JSON and
keep the original text as the default value in the resource file.

@github-actions github-actions Bot added enhancement New feature or request size/M and removed size/M labels May 13, 2026
@coderpurohit
Copy link
Copy Markdown
Author

coderpurohit commented May 14, 2026 via email

@rahul-vyas-dev
Copy link
Copy Markdown
Contributor

Hi @rahul Vyas, I’m a first-time contributor and I’ve been exploring the OrgExplorer codebase. I recently worked on PR #59 and would like to continue contributing. Could you suggest a beginner-friendly issue or improvement area I can work on next? Thanks!

Hey @coderpurohit, wlc to our community, we will open some beginner friendly issues soon once we start working. And don't forget to checkout our other projects that meet your niche and interest. Check for good first issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEATURE : Add basic routing and separate 404 page (React Router)

2 participants