Although learning React can be very interesting, the initial period can be confusing with its hooks, props and errors. Fortunately there are some straightforward tips which seasoned developers use to produce concise, secure and clear code. These can usually be learnt in 5 minutes.
Below are ten tips that skilled React JS development professionals use daily. Read on and you too can begin to apply them immediately.
1. Avoid Create React App and opt for Vite or a framework
Whilst many tutorial websites still recommend you use create-react-app, this was officially discontinued in February 2025 by the React team. To develop a basic application, Vite is ideal as it initialises projects in seconds. For a production quality site, start with a framework such as Next.js or React Router. These take care of features including navigation, data fetching and server-side rendering.
2. Replace additional divs with Fragments
As only one parent element can be returned by a component, novices commonly enclose content within tags. Too many divs can cause untidy code and even disrupt CSS such as Flexbox and Grid. Replace these with an unnamed Fragment tag: <>…</>. This allows you to group content without affecting the page in any way.
3. De-structure and define default props
Rather than continually typing ‘props.title’, and ‘props.size’ etc., firstly de-structure the props. For example: function Button({ label, size = "medium" }). Code can thus be condensed. Furthermore, it is immediately apparent to you and others what props are required by the component. Lastly, a default value ensures that the component will still function if a particular prop is not provided.
4. Be wary of the zero ‘falsey’ value
Although {items.length && } appears correct, if no items exist, then React will display ‘0’. This is because zero is an acceptable value for React to show. Convert the condition to always yield a boolean value – for example, {items.length > 0 && }. Where there is a choice between two options, use a ternary: {isLoggedIn ? : }.
5. Supply a function to update state based on previous state
If you run setCount(count + 1), this will only increment by 1. All instances of the function access the same previous state value. Instead, utilise a function: setCount(c => c + 1). React will continually provide the most up-to-date state value and so no information is ever lost.
6. Never modify state
Altering values in arrays (for example, with items.push(newItem)) or objects (such as setting user.name = "Sam") does modify data. But React will not recognise these changes and so the page will not refresh. Always generate new data. For arrays do: setItems([…items, newItem]) and for objects: setUser({ …user, name: "Sam" }). Likewise, modern JavaScript functions such as toSorted() and toReversed() also return new arrays and do not alter existing ones.
7. Force a component to refresh by altering its key
Suppose you want to wipe a form when someone views another profile. Rather than setting up an effect to reset all form fields, simply vary a component’s key. For instance: . React will dispose of the current version of the component and then re-initialise it. As a result, state is fresh. Few novices are aware of this highly beneficial tip.
8. Employ children to prevent prop drilling
Often data has to be sent down many component levels – this process is called prop drilling and soon becomes unwieldy. Frequently, however, this can be circumvented by making use of the special ‘children’ prop. Construct outer components, for example, and , and within these have them display {children}. Content can then be directly supplied by a parent component. Information remains in the correct location and intermediary components do not need to be aware of it.
9. Develop bespoke hooks for shared functionality
Should you repeatedly use identical code for useState and/or useEffect in different components (for example to monitor window dimensions or access local storage), then encapsulate this within a bespoke hook. An example might be useWindowSize(). Essentially, a custom hook is a function beginning with ‘use’, and which invokes other hooks. Components can then be slimmed down and functionality is centralised.
10. Install the React Developer Tools
This free browser add-on is available for Chrome, Firefox and Edge. It is one of the top tools for studying React. Within the Components tab you can view, in real time, the props, state and hooks of all components. The Profiler tab indicates which components refresh and how swiftly. Before resorting to console.log, consult this tab to investigate why an app may not be functioning as intended.
Conclusion
Whilst none of these tips require expert knowledge, collectively they address some of the most typical novice issues such as non-displaying pages, failure to refresh and falsey 0s, plus prop drilling. Select one or two to practise each week on a small project and soon they will become second nature.
As your projects expand to become complete products incorporating features such as login functionality and payment facilities, and then are used by thousands of people, the importance of quality increases. At this stage, engaging the services of a competent React JS development company can be appropriate. Alongside applying good practice, such a company will test, optimise and review code. Consequently, your app is of high quality from the outset.
Related: React tips