concept information in category isomorphic web applications
appears as: information, information

This is an excerpt from Manning's book Isomorphic Web Applications: Universal Development with React.
Users want to see the content of All Things Westies right away. Otherwise, they’ll get impatient and leave before seeing all the products and information being offered. Loading an SPA can be a slow experience for a user (especially on mobile phones). Even though the browser may connect quickly to your application, it takes time to run the startup code and fetch the content, which leaves the user waiting. In the best-case scenario, SPAs display loading indicators and messaging for the user. In the worst-case scenario, there’s no visual feedback, and the user is left wondering whether anything is happening.
Listing 2.6. Featured component—src/components/featured.jsx
import React from 'react'; const Featured = (props) => { const buildIngredients = (ingredients) => { #1 const list = []; ingredients.forEach((ingredient, index) => { list.push( <li className="item" key={`${ingredient}-${index}`}> {ingredient} </li> ); }); return list; } const buildSteps = (steps) => { #2 const list = []; steps.forEach((step, index) => { list.push( <li className="item" key={`${step}-${index}`}> {step} </li> ); }); return list; } return ( <div className="featured ui container segment six wide column"> <div className="ui large image"> <img src={`http://localhost:3000/assets/${props.thumbnail}`} /> </div> #3 <h3>{props.title}</h3> #3 <div className="meta"> Cook Time: {props.cookTime} </div> #3 <div className="meta"> Difficulty: {props.difficulty} </div> #3 <div className="meta"> Servings: {props.servings} </div> #3 <div className="meta"> Tags: {props.labels.join(', ')} </div> #3 <h4>Ingredients</h4> <div className="ui bulleted list"> {buildIngredients(props.ingredients)} #4 </div> <h4>Steps</h4> <div className="ui ordered list"> {buildSteps(props.steps)} #5 </div> </div> ); } Featured.defaultProps = { #6 labels: [], ingredients: [], steps: [] } export default Featured; #1 Function converts an array of ingredients into an array of list items; this is called from the render function. #2 Function takes in the steps array and converts it to a list item, called from render function. #3 Featured component is a container that renders information about the featured recipe; it renders a recipe passed in via props. #4 Function converts an array of ingredients into an array of list items; this is called from the render function. #5 Function takes in the steps array and converts it to a list item, called from render function. #6 Set properties that are arrays to defaults so if there’s no data, the component can still render. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":3,\"ch\":66},{\"line\":3,\"ch\":68}],[{\"line\":71,\"ch\":0},{\"line\":71,\"ch\":2}],[{\"line\":18,\"ch\":66},{\"line\":18,\"ch\":68}],[{\"line\":72,\"ch\":0},{\"line\":72,\"ch\":2}],[{\"line\":37,\"ch\":65},{\"line\":37,\"ch\":67}],[{\"line\":38,\"ch\":65},{\"line\":38,\"ch\":67}],[{\"line\":41,\"ch\":65},{\"line\":41,\"ch\":67}],[{\"line\":44,\"ch\":65},{\"line\":44,\"ch\":67}],[{\"line\":47,\"ch\":65},{\"line\":47,\"ch\":67}],[{\"line\":50,\"ch\":65},{\"line\":50,\"ch\":67}],[{\"line\":73,\"ch\":0},{\"line\":73,\"ch\":2}],[{\"line\":37,\"ch\":65},{\"line\":37,\"ch\":67}],[{\"line\":38,\"ch\":65},{\"line\":38,\"ch\":67}],[{\"line\":41,\"ch\":65},{\"line\":41,\"ch\":67}],[{\"line\":44,\"ch\":65},{\"line\":44,\"ch\":67}],[{\"line\":47,\"ch\":65},{\"line\":47,\"ch\":67}],[{\"line\":50,\"ch\":65},{\"line\":50,\"ch\":67}],[{\"line\":73,\"ch\":0},{\"line\":73,\"ch\":2}],[{\"line\":37,\"ch\":65},{\"line\":37,\"ch\":67}],[{\"line\":38,\"ch\":65},{\"line\":38,\"ch\":67}],[{\"line\":41,\"ch\":65},{\"line\":41,\"ch\":67}],[{\"line\":44,\"ch\":65},{\"line\":44,\"ch\":67}],[{\"line\":47,\"ch\":65},{\"line\":47,\"ch\":67}],[{\"line\":50,\"ch\":65},{\"line\":50,\"ch\":67}],[{\"line\":73,\"ch\":0},{\"line\":73,\"ch\":2}],[{\"line\":37,\"ch\":65},{\"line\":37,\"ch\":67}],[{\"line\":38,\"ch\":65},{\"line\":38,\"ch\":67}],[{\"line\":41,\"ch\":65},{\"line\":41,\"ch\":67}],[{\"line\":44,\"ch\":65},{\"line\":44,\"ch\":67}],[{\"line\":47,\"ch\":65},{\"line\":47,\"ch\":67}],[{\"line\":50,\"ch\":65},{\"line\":50,\"ch\":67}],[{\"line\":73,\"ch\":0},{\"line\":73,\"ch\":2}],[{\"line\":37,\"ch\":65},{\"line\":37,\"ch\":67}],[{\"line\":38,\"ch\":65},{\"line\":38,\"ch\":67}],[{\"line\":41,\"ch\":65},{\"line\":41,\"ch\":67}],[{\"line\":44,\"ch\":65},{\"line\":44,\"ch\":67}],[{\"line\":47,\"ch\":65},{\"line\":47,\"ch\":67}],[{\"line\":50,\"ch\":65},{\"line\":50,\"ch\":67}],[{\"line\":73,\"ch\":0},{\"line\":73,\"ch\":2}],[{\"line\":37,\"ch\":65},{\"line\":37,\"ch\":67}],[{\"line\":38,\"ch\":65},{\"line\":38,\"ch\":67}],[{\"line\":41,\"ch\":65},{\"line\":41,\"ch\":67}],[{\"line\":44,\"ch\":65},{\"line\":44,\"ch\":67}],[{\"line\":47,\"ch\":65},{\"line\":47,\"ch\":67}],[{\"line\":50,\"ch\":65},{\"line\":50,\"ch\":67}],[{\"line\":73,\"ch\":0},{\"line\":73,\"ch\":2}],[{\"line\":53,\"ch\":65},{\"line\":53,\"ch\":67}],[{\"line\":74,\"ch\":0},{\"line\":74,\"ch\":2}],[{\"line\":57,\"ch\":65},{\"line\":57,\"ch\":67}],[{\"line\":75,\"ch\":0},{\"line\":75,\"ch\":2}],[{\"line\":63,\"ch\":65},{\"line\":63,\"ch\":67}],[{\"line\":76,\"ch\":0},{\"line\":76,\"ch\":2}]]"} !@%STYLE%@!