You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-40Lines changed: 24 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -368,56 +368,33 @@ If you‘re having troubles understanding this example, I recommend the fantasti
368
368
369
369
_[Flow][] is a static type checker for JavaScript. This section is only relevant for you if you‘re using Flow in your application._
370
370
371
-
ReComponent comes with first class Flow support built in. By default, a ReComponent will behave like a regular Component and will require props and state to be typed:
371
+
ReComponent comes with first class Flow support built in.
372
+
When extending `ReComponent`, in addition to the `Props` and `State` types required by regular `React.Component`
373
+
we need to specify the third generic parameter which should be a union of all actions used by the component.
374
+
This ensures type-safety everywhere in the code of the component where the actions are used and
375
+
even allows [exhaustiveness testing] to verify that every action is indeed handled.
Without specifying our action types any further, we will allow all `string` values. It is, however, recommended that we type all action types using a union of string literals. This will further tighten the type checks and will even allow [exhaustiveness testing] to verify that every action is indeed handled.
@@ -438,7 +418,11 @@ Check out the [type definition tests](https://github.com/philipp-spiess/react-re
438
418
439
419
**Known Limitations With Flow:**
440
420
441
-
- While it is possible to exhaustively type check the reducer, Flow will still require every branch to return an effect. This is why the above examples returns `NoUpdate()` even though the branch can never be reached.
421
+
-`this.send` API for sending actions is preferred over `this.createSender`. This is because `this.createSender`
422
+
effectively types the payload as `any` (limitation we can't overcome for now), whereas `this.send` provides full type-safety
423
+
for actions
424
+
- While it is possible to exhaustively type check the reducer, Flow will still require every branch to return an effect.
425
+
This is why the above examples returns `NoUpdate()` even though the branch can never be reached.
0 commit comments