That was the last chapter of the book. I hope you enjoyed reading it and that it helped you to get traction in React. If you liked the book, share it as a way to learn React with your friends. It should be used as giveaway. In addition, you could take 5 minutes to write a quick review about it on Amazon.
前面一章就是全书的最后一章节。我希望你享受阅读本书的过程,也希望这本书对你学习 React 有所帮助。如果你喜欢这本书,请将其作为学习 React 的一种方法推荐给你的朋友们。授人玫瑰,手有余香。此外,若不介意的话请花上五分钟在亚马逊上写个短评。
But where can you go from here after reading this book? You can either extend the application on your own or give your own React project a shot. Before you dive into another book, course or tutorial, you should create your own hands-on React project. Do it for one week, take it to production by deploying it somewhere, and reach out to me on Twitter to showcase it. I am curious what you will build after you have read the book and I will gladly share it with my followers. You can also find me on GitHub to share your repository.
**但在阅读本书之后,你又将去向何处呢?**你可以自行扩展这个应用,也可以尝试构建属于自己的 React 项目。在你深入另一本书、课程或教程之前,你应该动手创建一个属于自己的 React 项目。持续做上一个星期,把它上线部署到某个地方,然后可以通过 Twitter 联系我把它展示出来。我很好奇你在看到本书之后会创造出点什么,我也很乐于跟我的粉丝们一起分享你的作品。你也可以在 GitHub 找到我并分享你的代码库。
If you are looking for further extensions for your application, I can recommend several learning paths after you have used only plain React in this book:
本书中我们只是操练了纯粹的 React,如果你需要进一步扩展你的应用程序,我可以再推荐几个学习途径:
- State Management: You have used React
this.setState()
andthis.state
to manage and access local component state. That's a perfect start. However, in a larger application you will experience the limits of React's local component state. Therefore you can use a third-party state management library such as Redux or MobX. On the course platform Road to React, you will find the course "Taming the State in React" that teaches advanced local state in React, Redux and MobX. The course comes with an ebook as well, but I recommend everyone to dive into the source code and screencasts too. If you liked this book, you should definitely checkout Taming the State in React. - **状态管理:**相信你已经使用过 React 中的
this.setState()
和this.state
,用于管理和存取组件内部状态。千里之行,始于足下。然而在更大型的项目中,你就会切身体会到 React 组件内部 state 的局限性。因此你可以使用一个第三方的状态管理库,比如说 Redux 或 MobX。你会发现在 Road to React 授课平台上,《驯服 React 中的状态》("Taming the State in React")这门课程将会传授 Redux、MobX 与 React 本地 state 的进阶内容。这门课程也会包含一本电子书,但我推荐大家可以深入到源代码和录屏教学中去。如果你喜欢这本书,那么毫无疑问你也应该看一看《驯服 React 中的状态》。 - Sample Projects: After learning plain React, it is always good to apply the learnings first in your own projects before learning something new. You could write your own tic-tac-toe game or a simple calculator in React. There are plenty of tutorials out there that use only React to build something exciting. Check out mine about building a paginated and infinite scrolling list, showcasing tweets on a Twitter wall or connecting your React application to Stripe for charging money. Experiment with these mini applications to get comfortable in React.
- **项目实例:**在学习了纯 React 内容过后,要将所学内容运用到自己的项目上,而不是急于学习其他新东西,这对你总是有好处的。你可以使用 React 编写自己的井字游戏(tic-tac-toe)或是一个简单的计算器。有很多不错的教程会教你,仅仅使用 React 就能打造出一些有意思的玩意儿。看看我所做的诸如 分页和无限滚动列表,在 Twitter 墙上展示推文 或是 为 React 应用集成 Stripe 支付功能(译者注:Stripe 类似于支付宝)。
- Code Organization: On your way reading the book you came across one chapter about code organization. You could apply these changes now, if you haven't done it yet. It will organize your components in structured files and folders (modules). In addition, it helps to understand and learn the principles of code splitting, reusability, maintainability and module API design.
- **代码结构:**在阅读本书的过程中,你应该对提到组织代码结构那一章有印象。如果还没来得及实践的话,你现在就可以实际运用起来,可以把你的组件们放到结构化的文件和目录(模块)当中。此外,这也能帮助你理解和学习关于代码拆分、可复用性、可维护性和模块 API 设计的原则。
- Testing: The book only scratched the surface of testing. If you are not familiar with the general topic, you could dive deeper into the concepts of unit testing and integration testing, especially in context of React applications. On an implementation level, I would recommend to stick to Enzyme and Jest in order to refine your approach of testing with unit tests and snapshot tests in React.
- **测试:**这本书对测试的涉及尚浅。如果你对测试这个大话题还不太熟悉的话,你应该尝试进一步了解单元测和集成测试的相关概念,特别是在 React 应用的上下文里面。从实现层面上来说,我会强烈推荐 Enzyme 和 Jest,通过单元测试和快照测试来改善你的 React 测试手法。
- Asynchronous Requests: You can substitute the native fetch API with third-party alternatives to perform asynchronous requests: superagent or axios. There is no perfect solution to make asynchronous requests. But by exchanging the buildings blocks around React, you make the experience how powerful it can be to have this flexibility. In frameworks you usually stick to one solution. In a flexible ecosystem like React you can exchange the solutions.
- **异步请求:**你可以使用执行异步请求的第三方库来替代原生的 fetch API:superagent 或 axios。发送异步请求并没有完美的解决方案。但是通过更换 React 外围的组成部分,你可以切身体会到在 React 当中拥有这种灵活性是多么的强大。在某些框架中通常你只能使用某一种方案,但是在诸如 React 这样的灵活的生态系统当中,你可以任意更换解决方案。
- Routing: You can implement routing for your application with react-router. So far, you only have one page in your application. React Router helps you to have multiple pages across multiple URLs. When you introduce routing to your application, you don't make any requests to your web server to fetch the next page. The router will do everything for you on the client-side.
- **路由:**你可以使用 react-router 为你的应用程序实现路由功能。到目前为止,你的应用程序还只有一个页面。React Router 则能够让你跨多个 URL 创建多个页面。在将路由引入你的应用之后,你不需要发送任何请求到服务端去获取下个页面。路由器(Router)将会帮你在客户端搞定一切。
- Type Checking: In one chapter, you have used React PropTypes to define component interfaces. It is a good practice to prevent bugs. But the PropTypes are only checked on runtime. You can go one step further to introduce static type checking on compile time. TypeScript is one popular approach. But in the React ecosystem, people often use Flow. I can recommend to give Flow a shot if you are interested to make your application more robust.
- **类型检查:**在某个章节,你已经使用过 React PropTypes 来定义组件接口。这是预防 bugs 的一种良好实践,但是 PropTypes 只能在运行时执行检查。你可以更进一步地,在编译时就引入静态类型检查。TypeScript 就是备受欢迎的手段之一。但在 React 生态当中,通常情况下大家会使用 Flow。如果你想要让你的应用程序更加健壮的话,我会推荐你去尝试一下 Flow。
- Tooling with Webpack and Babel: In the book you have used create-react-app to set up your application. At some point, when you have learned React, you might want to learn the tooling around it. It enables you to setup your own project without create-react-app. I can recommend to follow a minimal setup with Webpack and Babel. Afterward you can apply more tooling on your own. For instance, you could use ESLint to follow a unified code style in your application.
- **Webpack 和 Babel 相关工具:**在本书中你已经使用过 create-react-app 来创建应用程序。到了某个节点,当你已经对 React 足够了解的时候,你可能就想要学习跟 React 相关的一些工具。这可以让你不用 create-react-app 也能初始化自己的项目。我会推荐你先了解如何使用 Webpack 和 Babel 完成最少量的配置,然后你可以根据自己的情况去实践更多的工具。例如,你可以在应用程序中使用 ESLint 来统一代码风格。
- React Native: React Native brings your application on mobile devices. You can apply your learnings from React to ship iOS and Android applications. The learning curve, once you have learned React, shouldn't be steep in React Native. Both share the same principles. You will only encounter different layout components on mobile than you are used to in web applications.
- React Native:React Native 可以将你的应用程序带到移动设备上。React Native 使你能够把在 React 中所学到的知识应用到 iOS 和 Android 应用当中去。一旦你学会了 React,React Native 的学习曲线就应该不会那么陡峭,两者都是相同的原则和理念。你只是会在移动设备上碰到一些跟 Web 应用有所不同的布局组件。
In general, I invite you to visit my website to find more interesting topics about web development and software engineering. You can subscribe to get updates roughly every month to your inbox and you can decide to support this kind of content by being my Patron. Furthermore, the course platform Road to React offers more advanced courses to learn about the React ecosystem. You should check it out!
总之,我希望你能来我的网站看一看,你会发现更多关于 Web 开发和软件工程的有趣内容。你也可以订阅我的更新,大概每月一次就会送达你的收件箱,同时你可以通过 Patron 众筹来支持我的这些内容。此外,在通向 React 的道路(Road to React) 授课平台上会提供更多学习 React 生态圈的进阶课程。你不应该错过!
Once again, if you liked the book, I want you to take a moment to think about a person who would be a good match to learn React. Reach out to that person and share the book. It would mean a lot to me. The book is intended to be given to others. It will improve over time when more people read it and share their feedback with me.
请允许我再啰嗦一次,如果你喜欢这本书,我希望你能花点时间想一想谁比较适合学习 React。找到他们然后把这本书分享给他。这对我真的非常重要,这本书就旨在与他人分享。随着时间的推移,越来越多阅读本书的人会与我分享他们的看法和意见,这也会帮助我改进这本书。
Thank you a lot for reading the Road to learn React.
由衷地感谢你阅读这本书,《React 斩荆之路》。
Robin