concept component in category node

This is an excerpt from Manning's book Next.js in Action.
In step three, we’re expecting the React components that were rendered on the server to be ready in the browser. By the user clicking the button, they cause a change in state that causes components to be re-rendered. If all we had were static content, React would have to start at the beginning as soon as this button is clicked by creating new components and checking whether or not they exist in the DOM. This can have a negative impact on performance and cause undesired lag for the user. Instead, we need to pass the state of the application from the server to the browser, along with the HTML content. This allows React to reconstruct the virtual DOM so that when the user clicks the button to filter articles, it can be done efficiently. Thankfully, Next.js makes the handoff from server to browser seamless enough that we don’t have to think about it. This is a complex, error-prone process that every React app needs but shouldn’t have to manually implement.
Styles play a big role in any web application and Next.js apps are no exception. Once you have a large enough app, you’re going to want to make sure that your approach to implementing and maintaining styles is going to work for the long run and not to just get by for another week. Too often, we don’t really have an approach to styles – they’re thought of as an extension of the components that we build as part of the UI. In a way, this is true, styles exist to change the appearance of the components that we build. From another perspective, styles are a different animal when in terms of how the technology works and how we leverage CSS syntax to target page elements to change.
This page uses global styles to set the font-family CSS property on the <body> element. It uses locally scoped styles to change the size of the first letter of each paragraph. It’s important to remember that just because a style is global does not make it accessible to every page. This was my natural assumption when I was first learning Next.js – that by making a style global, it’s available on every page automatically. Global, in the context of styled-jsx, means that scope is removed. To make styles without scope available to every page, we have to define those styles in a component that’s used by every page. For example, in chapter 4 we created a layout component that was used by every page where we could include any global styles that we want to be available to every page.
Another challenge with scoped styles is when you need to customize the styles of components on your page. For example, in chapter 4, there was a need to override the color of link elements in our navigation component. To achieve this, we used the resolve function from styled-jsx in order to get the scoped class name of a style defined on our page and pass it to the component that we’re trying to customize. Additionally, we had to make sure that they styles are included in the page markup. This process is illustrated here:
Figure 5.7: Passing scoped styles to components on a page in order to customize them
![]()
The reason we have a <div> as the root page element with a root class is so that we can still scope our styles to the page, but not limit ourselves from using them with components that are on the page, such as Section. Let’s take look at the rendered CSS for a better understanding of how this works:
.root.jsx-3649877764 .sectionTitle { ... }Because we only applied :global to the .sectionTitle portion of the selector, it’s the only portion that doesn’t have scope. The .root class is scoped with .jsx-3649877764 meaning that our .setionTitle class will only apply to elements on this page. We can use the same technique with components that use other components and pass classes to them – we can make a CSS class global within the component.

This is an excerpt from Manning's book Getting MEAN with Mongo, Express, Angular, and Node.js 2ED.
This figure is a simple example to show how you can piece together the various parts of the MEAN stack into different architectures to answer the questions that your projects ask of you. Your options are limited only by your understanding of the components and your creativity in putting them together. There’s no one correct architecture for the MEAN stack.
In an Angular SPA, you don’t want the form to submit to a different URL, taking you to a new page. You want Angular to handle everything, so you’ll remove the form element’s action="" attribute and replace it with Angular’s ngSubmit event handler to call a public member in the component. The following code snippet shows how the event handler is used, adding it to the form definition, calling a function in the component that you’ll write in a moment:
<form (ngSubmit)="onReviewSubmit()">This line calls a public method on the component called onReviewSubmit when the form is submitted. You need to create this method, so you’ll add a simple method to location-details.component.ts to create a console log when the form is submitted:
Where’s the best place to put this logic? Any of the components in the routable area could be configured to get the URL parameter and call the API, but you want to display data in all three nested components. So you’ll go for the approach of using the “parent” Details page component to get the data and then pass it through to the three child components. First, you’ll add a method to your data service to call the API to get a single location by ID.

This is an excerpt from Manning's book Isomorphic Web Applications: Universal Development with React.
11. React renders the components.
The basics of React Router 4 are similar to those of React Router 3. You declare your routes using a Route component. You give it a path and a component to render. The big change is in where you declare your routes. In version 3, you have a single, centralized routes file. In version 4, you declare your routes inside the appropriate component. The following listing shows how you’d take the routes from the sharedRoutes.jsx file and put them in app.jsx instead.
Listing A.2. Declare the routes—components/app.jsx
// ... other code import { Link, Route, withRouter } from 'react-router-dom'; #1 import Cart from '../components/cart'; #2 import Products from '../components/products'; #2 import Profile from '../components/profile'; #2 import Login from '../components/login'; #2 const App = (props) => { return ( <div> <div className="ui fixed inverted menu"> <h1 className="header item">All Things Westies</h1> <Link to="/products" className="item">Products</Link> <Link to="/cart" className="item">Cart</Link> <Link to="/profile" className="item">Profile</Link> </div> <div className="ui main text container"> <Route path="/" exact component={Products} /> #3 <Route path="/products" component={Products} /> #4 <Route path="/cart" component={Cart} /> #4 <Route path="/profile" component={Profile} /> #4 <Route path="/login" component={Login} /> #4 </div> </div> ); }; export default withRouter(App); #5 #1 Imports the Route component and the withRouter higher-order component #2 Imports the various app components used in the routes #3 For paths that would result in multiple matches, make sure to use the exact option. #4 Each Route takes a path and a component. #5 Wraps App in the HOC withRouter. This ensures your components have access to the history and location props. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":2,\"ch\":8},{\"line\":2,\"ch\":25}],[{\"line\":3,\"ch\":8},{\"line\":3,\"ch\":25}],[{\"line\":3,\"ch\":64},{\"line\":3,\"ch\":66}],[{\"line\":31,\"ch\":0},{\"line\":31,\"ch\":2}],[{\"line\":4,\"ch\":0},{\"line\":4,\"ch\":66}],[{\"line\":5,\"ch\":0},{\"line\":5,\"ch\":66}],[{\"line\":6,\"ch\":0},{\"line\":6,\"ch\":66}],[{\"line\":7,\"ch\":0},{\"line\":7,\"ch\":66}],[{\"line\":19,\"ch\":8},{\"line\":19,\"ch\":66}],[{\"line\":20,\"ch\":8},{\"line\":20,\"ch\":66}],[{\"line\":21,\"ch\":8},{\"line\":21,\"ch\":66}],[{\"line\":22,\"ch\":8},{\"line\":22,\"ch\":66}],[{\"line\":23,\"ch\":8},{\"line\":23,\"ch\":66}],[{\"line\":29,\"ch\":15},{\"line\":29,\"ch\":26}],[{\"line\":9,\"ch\":18},{\"line\":9,\"ch\":19}],[{\"line\":26,\"ch\":2},{\"line\":26,\"ch\":3}],[{\"line\":29,\"ch\":29},{\"line\":29,\"ch\":30}],[{\"line\":29,\"ch\":64},{\"line\":29,\"ch\":66}],[{\"line\":35,\"ch\":0},{\"line\":35,\"ch\":2}]]"} !@%STYLE%@!