Tom Clark
Mar 20, 2022

I like the reasons you’ve laid out for this, and totally get *why* but think in a team this will cause more confusion than it does good.

I’m thinking of the zen of python here (google for it, its excellent!). “There should be one, and preferably ONLY one, way of doing things”.

If the hook is frequently used repeatedly within a component and has a low number of outputs (like useState) an array might be best… otherwise objects all the way. And if you need to use them repeatedly within a component, just don’t destructure them:

const thing1 = useHook()
const thing2 = useHook()

console.log(thing2.aProperty)

Tom Clark
Tom Clark

Written by Tom Clark

Fluid Dynamicist at the core, lover of chaos theory. Experienced scientist, developer and team lead working in wind energy — from startups to heavy industry.

Responses (1)