So we all know we can't put React hooks after or in conditionals as the documentation says.
function MyComponent(...) {
if (condition) {
React.useState() // not allowed
}
return <div></div>;
}
function MyComponent(...) {
if (condition) {
return null;
}
React.useState() // also not allowed
return <div></div>;
}
With the eslint plugin for react hooks, we get build errors saying the above are not allowed.
But why does the plugin not respond to this
function MyComponent(...) {
if (errorCondition) {
throw Error;
}
React.useState() // allowed???
return <div></div>;
}
Is it that this isn't allowed and the plugin isn't updated to catch this? or is this actually allowed? The documentation doesn't seem to say anything on this