Skip to content

Commit

Permalink
[docs] mention gh-1 in FAQ
Browse files Browse the repository at this point in the history
  • Loading branch information
Rossh87 committed Aug 23, 2021
1 parent 6cbecc7 commit 7968b38
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ A: Like [React Redux](https://react-redux.js.org/), [Redux-Saga](https://redux-s
A: Not yet, but stay tuned!

- **Q: How typesafe is the `dispatch` returned from `useFPReducer`?**<br>
A: Not completely, yet. The compiler will warn you if you try to dispatch an action with a `type` that's not in your reducer (assuming you've typed the reducer correctly), but it will *not* warn you if you try to give it a payload of the wrong type. In the near future, `useFPReducer` will automatically generate action-creator functions for you [Redux Toolkit](https://redux-toolkit.js.org/)-style, and they should be 100% typesafe.
A: Not completely, yet. The compiler will warn you if you try to dispatch an action with a `type` that's not in your reducer (assuming you've typed the reducer correctly), but it will *not* warn you if you try to give it a payload of the wrong type. As of v.2.1.0, `useFPReducer` will automatically generate action-creator functions for you [Redux Toolkit](https://redux-toolkit.js.org/)-style, and they should be 100% typesafe.

- **Q: Can I re-use the names of my action creators in a different component?**<br>
A: No. If you have two handler function, `handlerOne` and `handlerTwo`, and two components `ComponentOne` and `ComponentTwo`, you cannot call `useFPReducer` in `ComponentOne` with the handler-mapping object `{RUN_HANDLER: handlerOne}` and then call `useFPReducer` in `ComponentTwo` with the handler-mapping object `{RUN_HANDLER: handlerTwo}`. If the key `RUN_HANDLER` is re-used like this and `ComponentOne` is the first to render in your app, only `handlerOne` will be associated with the action `{type: 'RUN_HANDLER'}`. `handlerTwo` won't be registered with `react-use-fp`, and dispatching `{type: 'RUN_HANDLER'}` from `ComponentTwo` may cause `handlerOne` to run. So for now, please use unique keys for your handler-mapping objects, and have a look at [this issue](https://github.com/Rossh87/react-use-fp/issues/1) if you have ideas to improve this.

- **Q: None of this makes any sense, what should I do?**<br>
A: I'm sure the fault is mine, please feel free to [open an issue](https://github.com/Rossh87/react-use-fp/issues)! Suggestions/PRs/comments also welcome.

0 comments on commit 7968b38

Please sign in to comment.