Questions and answers
Here are some questions and answers to refresh your knowledge:
- What is a function component?
A function component is a function taking props as its input argument and returning elements. For an
App
component, we can display it by using its instance form,<App />
. To build an application, it's about putting a component under another component as a child and refining this process until we end up with a tree of components. - How do you write a function component?
The way to become adept at writing function components is quite similar to writing functions. Ask yourself what the props specification of the component is and what is returned for display. In a typical application, half of the components are designed for business requirements, but the other half normally comes from code refactoring. A study of Functional Programming (FP) can generally benefit you and take your UI skills to the next level.