Mark Erikson
Mark Erikson
Just tried this. It _does_ fix the issue... _if_ you infer `type RootState = ReturnType`. However, **it does _not_ fix the issue if you infer directly from `ReturnType`**. Which is...
The example was contributed by a user as we were putting together the docs for the hooks API. I'd say it's largely because most folks are used to seeing selectors...
I'd like to come up with a better example, but my current focus is on reworking the Redux core docs (per https://github.com/reduxjs/redux/issues/3592 ). For reference, I have an extensive post...
We might as well keep this issue open to cover that discussion.
The main question is whether there are any other fields in `state.profilePage`. If those are the only two fields, and you want to re-render when either of those change, then...
In that case the results should be basically equivalent.
Once the behavior is equivalent, no, it's really up to you, same as writing one large `useState` with an object vs multiple individual `useState`s vs a `useReducer`.
Short version is, RTK _is_ the right way to use Redux+TS together. There's less actual code to write, and RTK is designed to infer as many TS types as possible....
Extracting the `RootState` and `AppDispatch` types should be the same - `typeof store.dispatch` and `ReturnType` work the same way regardless of how you created the store. Reducer definitions are all...
I like this idea, but the PR is stale against `master`, and the new types are complex enough in their own way I'm not sure how to squeeze this in.