Non-Hook Helper Functions
You'll learn when a function shouldn't be a hook — and why the naming matters.
The Decision Point
Not every helper function in your React code needs to be a custom hook. In fact, most shouldn't be! The defining characteristic is simple: if a function doesn't call any hooks inside it, don't use the 'use' prefix.
Plain Functions Are Still Welcome
Imagine you're organizing tools in a workshop. Hooks are power tools that plug into React's electrical system (state, effects, context). But you still have plenty of hand tools — hammers, screwdrivers, measuring tapes — that work perfectly fine on their own without electricity.
The same applies to React functions. If you have a helper that:
- Formats a date string
- Validates an email address
- Calculates a discount percentage
- Transforms data structures
...and it doesn't need useState, useEffect, or any other hook, it's just a regular JavaScript function. Don't call it useFormatDate — call it formatDate.
Why the Distinction Matters
The use prefix signals to React's linter and to other developers: "This function follows the Rules of Hooks." If you break that convention, you're crying wolf. Future developers (including yourself) won't know if it's safe to call conditionally or in loops.
// ✅ Not a hook — regular function
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
// ❌ Misleading — doesn't call hooks, shouldn't use 'use'
function useCalculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
Key Takeaway: Reserve the use prefix exclusively for functions that call other hooks — plain helper functions are just regular JavaScript and should be named accordingly.