Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix/better error handling for hydrate#862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
amovar18 wants to merge3 commits intotesting-library:main
base:main
Choose a base branch
Loading
fromamovar18:fix/better-error-handling-for-hydrate

Conversation

amovar18
Copy link

What:
This PR adds a custom error message forhydrate function.

Why:
When hydrate function is called in non-browser environment it throws an errordocument is not defined which lead to a non-meaningful error message. This PR now aims to check if document is available or not and then throws a custom error message.

How:
This PR just provides a wrapper of anif else block inside thehydrate function and throws a custom error message sayingHydrate function can only be called in a client environment with a document available..

Checklist:

  • Documentation updated
  • Tests
  • Ready to be merged
  • Added myself to contributors table

SideNote: The documentation states that to usehydrate function for SSR testing of a hook but the conversation in the issue stated thatrender should be used in non browser environment andhydrate should be used on environment wheredocument is available. Should the documentation be updated?

@netlify
Copy link

netlifybot commentedJun 23, 2022

Deploy Preview forreact-hooks-testing-library failed.

NameLink
🔨 Latest commitce72ef4
🔍 Latest deploy loghttps://app.netlify.com/sites/react-hooks-testing-library/deploys/62b3f4d1a507e6000969c907

@mpeyper
Copy link
Member

Thanks@Amovar1. I do not have a heap of time to look at this, but I’ll try to get to it this weekend.

A couple of notes from my quick look now:

  1. Can we write a test for this? It should be possible to see the error by callinghydrate inthis test file as there is no document available there (it’s meant to replicate a ssr environment).
  2. I think the docs are ok on this as in the case of the ssr renderer,render simulates the server behaviour, andhydrate simulates the client behaviour. That said, updates to add clarity in the docs are always welcome (just be aware that our docs generation is currently broken so might be wasted effort).
  3. Speaking of the docs, don’t worry about the netlify errors. This was already broken and unrelated to your changes.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@amovar18@mpeyper

[8]ページ先頭

©2009-2025 Movatter.jp