You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should always use PascalCase when naming components. For example: TextField, NavMenu, and SuccessButton.
Use camelCase for functions declared inside components like handleInput() or showElement().
When creating hooks use withHookName().
5. Avoid Repetitive Code
If you notice you are writing duplicated code or components, convert it into a component, utility functions or hooks that can be reused. Do this with scalable intention.
6. Component Optimization
For functional components, instead of having large return statements, breaking the component down into smaller sub-components.
Use memoizing techniques where possible. Utilize the useMemo hook for values and useCallback for functions. Follow recommended React guidance.
Use the useEffect hook for performing side effects like data fetching or DOM manipulation after the component has rendered. However, use it judiciously as unnecessary effects can complicate code and affect performance. For a deeper understanding, we recommend reading this article.
7. Use Object Destructuring For Props
Instead of passing the props object, use object destructuring to pass the prop name. This discards the need to refer to the props object each time you need to use it.
importReactfrom'react';constMyComponent=({ id })=>{return<divid={id}/>;};
8. Document Each Component/Utility
New utility functions should be documented TSDoc commenting format.
Referencing our component docs.
If applicable add URL to online resources if they are meaningful for the component/method.
9. Write Tests for Each Component/Utility
Write tests for the components you create as it reduces the possibilities of errors. Testing ensures that the components are behaving as you would expect. In this project Jest is used, and it provides an environment where you can execute your tests.
New packages should only be integrated if the application doesn’t have the existing functionality and it cannot be added by implementing a small utility function. Use the https://snyk.io/advisor/ to assess the popularity, maintainability and security analysis. The package must be in good standing to be added to the project.
Update existing dependencies when you notice they are out of date.