- Do not name your components after the part of state they connect to.
- Do not name your components for the role they play in YOUR application.
- A component should be given ONLY the props it requires. This structure should be flat.
- Props should not be named according to the application state that gets passed in. Instead, they should be named according to their usage within the component itself.
- Composition is superior to import statements at the top and is the primary mechanism which allows your component to focus on doing ONE thing. Use it wherever, and whenever you can.
Here are some common ways presentational components “know” about a product:
- By using names for a particular part of the application’s state (e.g. EventStats)
- By using names based on the role the component plays in the application (e.g. RegistrationConfirmation)
Some common ways presentational components “know” about a platform:
- By styling via CSS or RN style definitions rather than with components and semantic props (e.g. assigning props which dictate presentation is fine, just do
color={”success”}
rather thancolor={‘#00cc66’}
) - By using controls provided by React or React Native (e.g. div, button, View, Text, etc) By doing anything that depends on a browser or native app context (e.g. urls, accessing window, checking screen width, etc)