
Ask HN: Creating a web UI/UX with React.js - backslash_16
A few days ago I started rebuilding my side project&#x27;s web UI in React.js, mostly because I want to learn one of the new front-end libraries&#x2F;frameworks, and because it will be good to remove the server side rendering and communicate between the frontend and backend using only an API.<p>Building components in React, using JSX is pretty straightforward. I can see a lot of potential value in separating my UI into many small components which I then compose.<p>What I&#x27;m lost at is three things.<p>1) How should I handle what I know as nested templates, or nested layouts? In case that isn&#x27;t super clear I mean the homepage styling and header&#x2F;footer, the user page styling and menu bar, and other concerns like that.<p>2) I&#x27;ve been using seed data to create my components so far, is using them with my API as simple as getting and posting what I need and passing it to the components?\<p>3) Navigation - I&#x27;m used to making a request to the server and having it return the correct view with all of the templates composed together in all their glory (boring I know :D). With react is there an official way of doing navigation? I&#x27;ve found some react-router libraries but none of them are officially from Facebook or the React.js team so I&#x27;m not sure if they are good, or if I am missing an official one.<p>Any advice or answers for these questions is appreciated!
======
djhartman
1) A common pattern is having “page” components that render different layouts.

2) Yes, start out by learning to fetch data in componentDidMount and then
calling set state with the result. It’s usually a good idea to do this at the
top level of your app and pass it down to child components. Don’t look into
Redux or MobX or anything like that until you run into problems. Most people
do not need a separate library for managing state.

3\. react-router is not “official” but it’s pretty damn close, probably the
most popular. Look into next.js if you want client and server side routing.

~~~
backslash_16
Thanks, this kind of advice is what I was looking for.

Sounds like I was overthinking calling the API, and I'll be using react-router
for navigation.

------
based2
[https://www.reddit.com/r/reactjs/](https://www.reddit.com/r/reactjs/)

[https://www.reddit.com/r/javascript/comments/8fhtp0/10_exper...](https://www.reddit.com/r/javascript/comments/8fhtp0/10_expert_reactjs_tips_that_you_need_to_know_today/)

[http://books.goalkicker.com/ReactJSBook/](http://books.goalkicker.com/ReactJSBook/)

