Learn about common React anti-patterns and best practices, including the use of useState instead of variables, declaring CSS outside of components, and when to use useCallback and useEffect to optimize function and effect triggers.
Table of contents
In This ArticleUse useState Instead of VariablesDeclare CSS Outside ComponentsList of Free Image Tools Every Frontend Developer NeedsUse useCallback To Prevent Function RecreationsUse useCallback To Prevent Dependency ChangesUse useCallback To Prevent useEffect TriggersAdd an Empty Dependency List to useEffect When No Dependencies Are RequiredAlways Add All Dependencies to useEffects and Other React HooksTop 10 Celebrities Who CodeDo Not Use useEffect To Initiate External CodeDo Not Wrap External Functions in a useCallbackDo Not Use useMemo With Empty Dependency ListDo Not Declare Components Within Other ComponentsDo Not Use Hooks in If Statements (No Conditional Hooks)Do Not Use Hooks After Return (No Conditional Hooks)Let Child Components Decide if They Should RenderUnderstanding useEffect, useRef and Custom HooksUse useReducer Instead of Multiple useStateWrite Initial States as Functions Rather Than ObjectsUse useRef Instead of useState When a Component Should Not RerenderDennis Persson Follow2 Comments
Sort: