Bad
const [myValue] = useCustomHook();
//or
const [myValue, setMyValue] = useCustomHook();
//or
const [myValue, setMyValue, isMyValueValid] = useCustomHook();
Cons:
in TS (depending on your liniting settings) you can't use isMyValueValid
without actually using setMyValue
.
Good
const {myValue, setMyValue, isMyValueValid} = useCustomHook();
//or
const {myValue} = useCustomHook();
//or
const {isMyValueValid} = useCustomHook();
//or
const {myValue, isMyValueValid} = useCustomHook();
//or
const {myValue, setMyValue} = useCustomHook();
//or
const {setMyValue} = useCustomHook();
//and so on ...
Pros: You can destruct any subset of fields you want to expose, regardless the order. You have to use defined field names (better consistency)