React App isn't showing components in localhost browser when I run 'Npm run dev'

3 weeks ago 16
ARTICLE AD BOX

1. Missing Component Import

In App.jsx, the Experience component is used but not imported:

<Experience />

Fix:

import { Experience } from "@/sections/Experience";

2. Incorrect Inline Style Syntax

In your Hero component, dynamic styles are incorrectly defined:

left: `{Math.random() * 100 }%`, top: `{Math.random() * 100}%`,

This passes invalid string values instead of evaluated expressions.

Fix:

left: `${Math.random() * 100}%`, top: `${Math.random() * 100}%`,

3. Missing key Prop in List Rendering

When rendering elements using .map(), React requires a unique key:

{[...Array(30)].map((_, i) => ( <div className="..." /> ))}

Fix:

{[...Array(30)].map((_, i) => ( <div key={i} className="..." /> ))}

4. Invalid JSX Attribute (class vs className)

React uses className instead of class:

<span class="...">

Fix:

<span className="...">

5. Missing Imports for Used Components

Ensure all referenced components are properly imported:

import Button from '@/button'; import { ArrowRight } from 'lucide-react';

6. Path Alias Configuration (@/)

If you are using @/ imports, ensure it is configured in vite.config.js:

import path from "path"; export default { resolve: { alias: { "@": path.resolve(__dirname, "./src"), }, }, };

Debugging Recommendation

Open the browser developer console (F12 → Console). You will likely see errors such as:

Component is not defined

Module not found

JSX syntax issues

Read Entire Article