While simple, today I used this trick to write the code I wanted. Variable assignment of a function is a valid, communicative way to alias a function in JavaScript.
const clearFilters = () => setFilters({});
// Use the same behavior when starting a new search.
const startNewSearch = clearFilters;
// These create the same result.
clearFilters();
startNewSearch();
In this case, calling clearFilters didn’t fit with a click handler on a button
labeled “Start New Search.” With this technique, was able to call the function I
wanted, abstracting its implementation.