Ask coding questions

← Back to all posts
React Importing and Routing issues
9ggy

So I started learning React.js yesterday by following a YouTube tutorial, and I have ran across a few issues. My main issue is that whenever I try to import my own components from another file or use the Route and Switch component, my website preview goes blank. If someone could help me or explain what I am doing wrong it would be greatly appreciated!

I also installed everything and added the path names correctly; there were no errors, just a blank screen.

Comments
hotnewtop
Coder100

Hi, the inspect console has given you some nice errors:

You must put it in a Routes element, check your documentation!

by the way, it is good practice to have your function names be PascalCase, so change line 17 to function NewMeetupsPage so you can do <NewMeetupsPage />

9ggy

Thank you @Coder100! I didn't even think to check the console.

9ggy

@Coder100

Now that i imported Routes and Route and did what you said, i get a new error:

Coder100

right, you have to use Route like this:

@9ggy

9ggy

@Coder100, sorry to annoy you again but I have another issue. I have the App function set like this:

But I get this error in the console:

Coder100
9ggy

Now my code is throwing this error:

@Coder100

Coder100

remove the browserRouter in main.jsx? @9ggy

9ggy

let me try
@Coder100