r/reactjs • u/timmonsjg • Dec 03 '18
Needs Help Beginner's Thread / Easy Questions (December 2018)
Happy December! βοΈ
New month means a new thread π - November and October here.
Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! Weβre a friendly bunch. No question is too simple. π€
π Want Help with your Code? π
- Improve your chances by putting a minimal example to either JSFiddle or Code Sandbox. Describe what you want it to do, and things you've tried. Don't just post big blocks of code!
- Pay it forward! Answer questions even if there is already an answer - multiple perspectives can be very helpful to beginners. Also there's no quicker way to learn than being wrong on the Internet.
Have a question regarding code / repository organization?
It's most likely answered within this tweet.
New to React?
π Here are great, free resources! π
38
Upvotes
View all comments
1
u/sidx64 Dec 25 '18
Hi all! I am just starting with ES6 and new to React, and I need help with react-router-dom!
Any help would be greatly appreciated!
I have a menu bar, and I have 3 items on it. I want one of 3 components to be displayed when the appropriate menu item is clicked. I used HashRouter and got the component routing working. But I seem to have broken something. When the page loads, the first component is selected by default. But when I click on the second one, the first one is not un-selected. The 1st component goes away though. can someone tell me what I doing wrong?
On page load https://imgur.com/LAasBz8On clicking second item https://imgur.com/8WN2WjJ
Code:
Here's my NavBar component
This is the HomePage (main) component where everything starts
Edit: Sorry for the huge amount of code!