-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Rewrite "Redux Essentials" tutorial to be TS-first and show RTK 2.0 usage #4393
Comments
Hey, it is an interesting task. I am taking a stab at it. :) |
@zvolcsey Hiya! Appreciate the offer of help. Normally I'd go ahead and coach you through contributing to a docs page, but this particular page is one that I do intend to work on myself in the near future, so probably best if we save that one for me to tackle. Just to check, any of the other open docs issues sound like something you'd like to help with? |
Thanks for the answer. I got it. I'll look for other open issues. :) |
Alternately: it would still be really neat to have full-blown tutorials that let you toggle between JS and TS. As noted above, this would be non-trivial. Really, the biggest issue would be around trying to write the content in a coherent way that makes sense no matter which version you have toggled on. But, there is at least a good example of this now. The Vue docs do this with "Options API" vs "Composition API", and the display mechanism is "just" toggling some CSS classes:
Maybe it's worth taking a stab at this. The other issue is that the sandboxes would probably need to be TS, but that would be an issue for people reading along in JS mode. |
FWIW, I've settled on actually rewriting the tutorial to be TS-first. Don't have an ETA on when, though. |
Also figure out how to add a good https://twitter.com/MichaelWealcome/status/1670763631338766337 |
I hope to actually start working on this in the next couple weeks! My first task will be to modernize the existing "Essentials" and "Fundamentals" example apps to use Vite instead of the current CRA4. This will both speed up build times and resolve the previously reported issues with Webpack 4 and Node/OpenSSL errors. I've got the setup changes figured out, and tomorrow I should be able to get the repo histories rewritten to have those changes in place. After that, I'll start trying to plan out changes to the actual "Essentials" tutorial. My biggest question is around changes to content:
As always, the trick is to both come up with example features in the app that justify using those features, and have it make sense in the context of the app and the source code. I'd appreciate suggestions for potential features to the example app that would justify these! (@EskiMojo14 just suggested maybe using the listener middleware to add a toast feature, which could work!) |
Pleased to report I've started the TS conversion effort! My first goal is to convert the entire Once I've got the entire commit sequence converted to TS, I'll step back and start figuring out what additional code changes I want to make (new features, etc). WIP is available at: (As a side note, at some point I apparently ran across https://timothycurchod.com/writings/redux-essentials-app-in-typescript , which does a similar conversion. @timofeysie , thanks for taking the time to do that conversion and put up that post! I'm going to do my own conversion independently, partly because I want to refresh my memory of what all I did in the original code. It'll be interesting to see how close we end up!) |
Was able to come up with a decent motivation for both "1 action -> many reducers" (auth logout clearing Put together first draft impls for both of those here: |
While not directly related, it might be worth coming up with a better tagline and basic description than "predictable state container". A learner was confused and had no idea what that meant. Maybe ought to copy-paste the "Redux helps you manage "global" state" paragraph from the "Essentials" tutorial into the "Getting Started" page, and also come up with a better 1-liner from the home page. |
It's pretty hard to distill Redux down into a tagline. The shortest I can come up with is "A clear and consistent way to keep track of app state and ensure that different parts of an app have access to the most up-to-date data for building scalable and maintainable applications." That could be re-worded a bit to avoid saying app three times I suppose. |
Maybe something like "A library for predictable global state management in JS apps" ? |
Long-overdue update! As of yesterday I have a complete draft that revamps the "Essentials" app and Parts 3-8 of the tutorial to teach RTK and the app using TS for everything, as well as improving many of the explanations (more concepts like I need to do a review of Parts 1 and 2 to see if there's any changes worth making there, review the content changes, and then finalize this. Would definitely appreciate any feedback! Hopefully I'll have this done in the Near Future (TM)! |
THIS IS NOW LIVE! Thrilled about this! Improvements in the new tutorial version:
|
@markerikson Hello, thank you for your project. I'm not sure where I could post a feedback, but I have redux architecture, which I can't implement with @redux-toolkit. Basically I have multiple projects, which has an action, which triggers multiple reducers. |
@JustFly1984 this isn't the right place for that question - could you post this in the "Discussions" section? (And yes, you can absolutely handle one action in multiple reducers with RTK - in fact, the new tutorial even has a section explaining that concept: https://redux.js.org/tutorials/essentials/part-4-using-data#handling-actions-in-multiple-slices ) |
The "Essentials" tutorial currently uses only plain JS for all of the examples and content.
If you want to learn how to use Redux with TS, we have two separate pages:
Unfortunately neither of those have any larger context for how TS gets used in practice.
I want the "Essentials" tutorial to cover TS usage. However, some of the suggested approaches are impractical:
I think the best approach is to add a "Redux Essentials, Part 9: Redux and TypeScript" page that would cover the TS material as a capstone to the tutorial sequence. I'm picturing a page that would run through some of the key code sections and API examples from the earlier pages in the tutorial, and explain how you'd write that same code from scratch with TS.
There was also a great suggestion on Twitter here at https://twitter.com/MikeLunarLandis/status/1551777390447079425 :
I think that strikes a good balance between showing meaningful examples of TS usage, and not having to maintain multiple copies or weird back-and-forths in the main tutorial sequence.
The text was updated successfully, but these errors were encountered: