-
Notifications
You must be signed in to change notification settings - Fork 232
Release/5.0.0 docs #529
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Release/5.0.0 docs #529
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c15707e
docs: update readme
joshuaellis 34fa682
docs: add renderer doc
joshuaellis 684b2f1
docs: copy readme updates to introduction
joshuaellis 8abd2f0
docs: update api-reference
joshuaellis f59f568
refactor: revert examples
joshuaellis 71762aa
refactor: Include more caveats
joshuaellis 7481d77
docs: create installation page and remove SSR to be in own page
joshuaellis e107bd9
docs: Update README.md with suggestion
joshuaellis 05dad4f
docs: add dedicated SSR page
joshuaellis c88c743
docs: update with suggestions
joshuaellis 05c9af5
docs: update with suggestions
joshuaellis 1aa5465
docs: update with suggestions
joshuaellis a461a6c
docs: change ssr-hooks to ssr
joshuaellis aa8b174
docs: add explicit menu entry for new page
mpeyper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
name: Renderer | ||
route: '/renderer' | ||
--- | ||
|
||
# Render Engine | ||
|
||
## Overview | ||
|
||
React requires a rendering engine, typically when creating an application people use `react-dom`. | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
When running tests, React still requires an engine. We currently support two different engines – | ||
`react-test-renderer` & `react-dom`. If you have both installed in your project, by default we will | ||
use `react-test-renderer`, assuming you're using the default imports: | ||
|
||
```js | ||
import { renderHook } from '@testing-library/react-hooks' | ||
``` | ||
|
||
It does this because the library runs a check for available renderers, in the order: | ||
|
||
- `react-test-renderer` | ||
- `react-dom` | ||
|
||
If neither are available you will see an error asking you to check that one of the above is | ||
installed. If only one is installed, then it will use that renderer. | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Being specific | ||
|
||
If, however, for certain tests you want to use a specific renderer (e.g. you want to use `react-dom` | ||
for SSR) you can import the server module directly: | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```ts | ||
import { renderHook } from '@testing-library/react-hooks/server` | ||
``` | ||
|
||
We have the following exports available: | ||
|
||
```ts | ||
import { renderHook, act } from '@testing-library/react-hooks' // will try to auto-detect | ||
|
||
import { renderHook, act } from '@testing-library/react-hooks/dom' // will use react-dom | ||
|
||
import { renderHook, act } from '@testing-library/react-hooks/native' // will use react-test-renderer | ||
|
||
import { renderHook, act } from '@testing-library/react-hooks/server' // will use react-dom | ||
``` | ||
|
||
## Caveats | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Auto detect | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The auto detection function may not work if tests are bundled to run in the browser. | ||
|
||
### SSR | ||
|
||
While calling `renderHook` from `@testing-library/react-hooks/native` and | ||
`@testing-library/react-hooks/dom` will return the same `RenderHookResult` as documented | ||
[here](/reference/api#renderhook-result), using `@testing-library/react-hooks/server` will return an | ||
additional function: | ||
|
||
```ts | ||
function hydrate(): void | ||
``` | ||
joshuaellis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Remember, state will not update with SSR unless `hydrate` is called. For more information on | ||
`hydrate` see the [API documentation](/reference/api#hydrate). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.