Skip to content

On error 2#76

Open
dwjohnston wants to merge 2 commits into
astoilkov:mainfrom
dwjohnston:onError-2
Open

On error 2#76
dwjohnston wants to merge 2 commits into
astoilkov:mainfrom
dwjohnston:onError-2

Conversation

@dwjohnston

@dwjohnston dwjohnston commented Nov 18, 2024

Copy link
Copy Markdown

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
Copy Markdown
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