-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Designing React Hooks the Right Way
By :
"This pattern is designed to encourage the creation of these simple components that should comprise large portions of your apps." – Sophie Alpert
In this section, we are going to introduce you to the function component. When the function component was first introduced in React 0.14 in August 2015, it was named as a stateless pure function:
function StatelessComponent(props) {
return <div>{props.name}</div>
}
The main intention was that "stateless pure-function components give us more opportunity to make performance optimizations."
A function component with no state, by default, is designed to take the following function form:
Figure 1.2 – Function component definition
We are going to explore parts of a function component in detail in the next subsections.
The input argument of this function is referred to as a prop. Props take an...
Change the font size
Change margin width
Change background colour