I'm from a Java background and new to ReactJS. So sorry if this is a dumb question, but I'be been stuck on this issue for a few days. Please help if you can.
My understanding is that react is for single-page apps. I've done some test development over the last couple of weeks and have been playing with Router etc. But I can't get my head around how you use react to create different content on different URLs. This is what I am trying to emulate:
- http://localhost:3000- a blank page with a Sign-in box
- http://localhost:3000/home - a dashboard with a menu bar across the top
- http://localhost:3000/about - a page with other information in but the same menu bar as 'home'
I don't want anyone to respond with details on how to create the components/layouts (I am very familiar with CSS, HTML, etc), what I don't understand is how to create a 'single-page app' with totally different content against different URLs (route paths).
If this was java, I would template the HTML and different pages would be served for different URLs. But that is server-side.
I've tried assigning a component to different routes: <Route path="/home" exact component = {Home} />
and building the content in that component but that doesn't work (I think I'm stuck in Java land and still thinking of 'serving' content).
When I look at Facebook (provider of React) it seems like all the menu actions along the top open in the same page, but I can not work out how different components can be hiding?? and appearing?? based on different routes clicked.
Maybe I've got this totally wrong and unique HTML pages are used for different routes??
Please let me know what best practice is and how I achieve this.
If you can point me to youtube videos or some simplified walk-throughs I would be very very grateful.
I've searched the web for things like "different react components on different routes", but haven't found anything that really shows how this works and what best practice is.
react-router-dom
which allows inside app content change based on url/route – Youmans<Users />
and<About />
share a common component ( like a menu), then this will be returned in both of these components (i.e. that these tags represent the entirety of the root div of the page)? – Dingus