Skip to content

Conversation

@dwjohnston
Copy link

@dwjohnston dwjohnston commented Nov 18, 2024

Goes one step further than #75 - if the onError function throws an error, then the hook will throw that error.

const [error, setError] = useState<null | Error>(null)

// Nice little React short cut - we can ignore rules of hooks if we are throwing errors.
if(error){
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this makes sense to me, but I'm wondering if it's a bit unconventional.... do people expect hooks to throw errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants