Creating a Universal JavaScript app
At this stage of the chapter, we should have got most of the basics that we need to transform our sample app into a full Universal JavaScript app. We met Webpack, ReactJs, and analyzed most of the patterns that help us to uniform and differentiate the code between platforms as needed.
In this section, we will keep improving our example by creating reusable components, by adding universal routing and rendering, and finally universal data retrieval.
Creating reusable components
In the previous example, we created two very similar components: JoyceBooks
and WellsBooks
. These two components are almost identical; the only difference between them is that they use different data. Now imagine a real case scenario where we might have hundreds or even thousands of authors... Yes, it wouldn't make much sense to keep having a dedicated component for every author.
In this section, we are going to create a more generic component and update our routing to be able to have...