Skip to content

Commit f34c00c

Browse files
committed
Update more documentation
1 parent da4eb5a commit f34c00c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

doc/TESTING.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ for how to write tests for real-world scalajs-react applications.
4242

4343
# `ReactTestUtils [SINCE 3.0.0]`
4444

45+
`ReactTestUtils` has been rewritten for scalajs-react v3 and React v18.
46+
What used to be `ReactTestUtils` prior to scalajs-react v3 has been renamed to `LegacyReactTestUtils`.
47+
4548
Read through the following for how to test with `ReactTestUtils`.
4649

4750
```scala
@@ -88,6 +91,8 @@ object TestUtilsDemo extends TestSuite {
8891

8992
# `LegacyReactTestUtils [DEPRECATED IN 3.0.0]`
9093

94+
This used to be called `ReactTestUtils` prior to scalajs-react v3 and React v18.
95+
9196
The main bucket of testing utilities lies in `japgolly.scalajs.react.test.LegacyReactTestUtils`.
9297

9398
Half of the methods delegate to React.JS's [React.addons.TestUtils](https://facebook.github.io/react/docs/test-utils.html)
@@ -161,7 +166,19 @@ s run component
161166

162167
# Testing props changes
163168

164-
When you want to simulate a parent component re-rendering a child component with different props,
169+
If you're using scalajs-react v3 and React v18, simply call `.render` from your React root. Example:
170+
171+
```scala
172+
ReactTestUtils.withRendered(Carrot.Props("1").render) { t =>
173+
for {
174+
_ <- t.root.render(Carrot.Props("1").render)
175+
_ <- t.root.render(Carrot.Props("2").render)
176+
} yield ()
177+
}
178+
```
179+
180+
If you're not using scalajs-react v3 and React v18, then
181+
when you want to simulate a parent component re-rendering a child component with different props,
165182
you can test the child directly using `LegacyReactTestUtils.{modify,replace}Props`.
166183

167184
Example of code to test:

doc/changelog/3.0.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
- Monadic hooks! [See documentation here](../HOOKS.md).
2525

26-
- `ReactTestUtils` has been replaced. [See a demo here](../TESTING.md), and see below a migration script.
26+
- `ReactTestUtils` has been replaced. The old version has been renamed to `LegacyReactTestUtils`. [See a demo here](../TESTING.md), and see a migration script below.
2727

2828
- `Renderable` typeclass for anything that React can render
2929

0 commit comments

Comments
 (0)