You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you want to request a feature or report a bug? feature
What is the current behavior?
Currently, if a component uses the throw keyword and still has hooks declared after it, the lint rule warns that it is an incorrect use. However, it may be a false positive when throw is being used to assert a component is being used correctly.
exportfunctionComponentUsingReduxContext(){constredux=React.useContext(ReactReduxContext)if(redux===null){thrownewError('ComponentUsingReduxContext mounted outside a redux Provider')}// more validation, initializing, etc// ...// causes a lint warningReact.useEffect(()=>{})returnnull}
What is the expected behavior?
throw new Error, or at least one where the Identifier's name.endsWith('Error'), could be considered an exception to the "no early returns" rule as the component will never try to reuse the state from the current render.
Currently, when you suspend by throwing a Promise, you also lose your state, so arguably all throws could be ignored, but I see that more as a bug with suspending than intended behavior.
The text was updated successfully, but these errors were encountered:
Do you want to request a feature or report a bug? feature
What is the current behavior?
Currently, if a component uses the
throw
keyword and still has hooks declared after it, the lint rule warns that it is an incorrect use. However, it may be a false positive whenthrow
is being used to assert a component is being used correctly.What is the expected behavior?
throw new Error
, or at least one where theIdentifier
'sname
.endsWith('Error')
, could be considered an exception to the "no early returns" rule as the component will never try to reuse the state from the current render.Currently, when you suspend by throwing a
Promise
, you also lose your state, so arguably allthrow
s could be ignored, but I see that more as a bug with suspending than intended behavior.The text was updated successfully, but these errors were encountered: