Naming may sound trivial, but there are some standard practices in React that you should comply with. These practices may vary from project to project, but keep in mind that you should respect at least the ones that are mentioned here. In other cases, check your project's style guide and possibly your linter configuration.
A component name should start with an uppercase letter unless it's a HOC. Use the component name as the filename. The filename should be in UpperCamelCase (for more information on CamelCase, see https://en.wikipedia.org/wiki/Camel_case):
// bad someSection.js // good SomeSection.js or SomeSection.jsx // Current Airbnb style guide recommends .jsx extension though.
The following are rules on importing your component:
This is a valid point as in some tools you may benefit from seeing the proper component names. Following this pattern is optional and up to the team to decide upon.
One can create a HOC that takes care of the displayName prop. Such a HOC can be reused on top of the HOCs we created in Chapter 1, React Component Patterns.
When defining new props, please avoid the common props that used to mean something else. An example may be the style prop we used to pass styles to our components.
Please check out the following links to check what props you should avoid using: