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
Do not include extension if it is in default resolved extensions (by webpack / CRA): ./file over ./file.ts
Do not write index in the path: ./dir over ./dir/index
Do not duplicate naming in path: ./button over ./button/button (use index file for reexport)
Import / Export
Prefer named exports over default exports
Using aliases (@app/)
When resolving is outside your current scope (../../../smth/...) - use aliases. Prefer @app/smth/...
When resolving is inside your current scope (./components/ from @app/page/Home) - Don't use aliases. As you would prefer a relative path, then you are not relying on app structure (directory @app/page/Home could be easily moved somewhere)
One exclusion from this rule is common resolvings. For them prefer aliases. Example: @app/config instead of ./config
React
Components
Use functional components instead of class components
Components should expose as less controls as it should. (Use useImperativeHandle to expose component API. Never expose internal variables unless really needed)
Avoid code duplication as much as possible. (More code = more errors)
Use useCallback / useMemo for performance optimizations wisely.
Event names:
handleItemClick - when you define event handler (usually in a container)
onItemClick - when it is a prop
Prefer useRef over useState when you don't need visual component update (redraw)
Other
Redux
Prefer using @reduxjs/toolkit instead of reselect
Styling
For styling components use styled-components library
Styling components should be done in a separate files with .styles.ts extension