Where possible, return two or fewer values from a hook, and return them in a tuple, like React.useState
(if you have no choice but to return more than three values, return them as a single object instead).
Examples of incorrect code for this rule:
function useFoo() {
const bar = 'bar';
const baz = 'baz';
const qux = 'qux'
return [bar, baz, qux];
}
Examples of correct code for this rule:
function useFoo() {
const bar = 'bar';
const baz = 'baz';
return [bar, baz];
}
function useFoo() {
return {
bar: 'bar',
baz: 'baz',
qux: 'qux',
};
}
If you do not want to enforce a stict return style from React hooks, you can safely disable this rule.