TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Creating a web UI/UX with React.js

5 点作者 backslash_16大约 7 年前
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!

2 条评论

djhartman大约 7 年前
1) A common pattern is having “page” components that render different layouts.<p>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.<p>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.
评论 #16954229 未加载
based2大约 7 年前
<a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;reactjs&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;reactjs&#x2F;</a><p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;javascript&#x2F;comments&#x2F;8fhtp0&#x2F;10_expert_reactjs_tips_that_you_need_to_know_today&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;javascript&#x2F;comments&#x2F;8fhtp0&#x2F;10_exper...</a><p><a href="http:&#x2F;&#x2F;books.goalkicker.com&#x2F;ReactJSBook&#x2F;" rel="nofollow">http:&#x2F;&#x2F;books.goalkicker.com&#x2F;ReactJSBook&#x2F;</a>