-
-
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
[Docs Rewrite] New Page: Style Guide #3601
Comments
Initial Style Guide Research NotesThe Redux docs have always been very unopinionated. The purpose of a "Style Guide" page is to specifically list our recommended approaches for various concepts, to provide guidance to the community on best practices. I'm explicitly modeling this page on the Vue docs page at https://vuejs.org/v2/style-guide/ . Vue Style Guide - Summary and NotesVue Rule Categories
Vue RulesPriority A
Priority B
Priority C
Priority D
Observations
I'm curious how we can actually implement some of the highlights and formatting that exist in the Vue page using Docusaurus. @wgao19 , @endiliey , @yangshun : any ideas? Redux RulesThis is an initial list of rules that I would want the docs to express an opinion on, with initial categories. I am totally open to suggestions for improving this list: additional topics we should cover, specific points of emphasis, altering categories, etc. Priority A (prevents errors):
Priority B
Priority C
Thoughts? |
I took a quick look at the Vue Style Guide. Having an official battle-tested opinion would be a great addition to the docs. Having a background for the code might be harder to do in D1 but it's very easy in D2. Maybe we could port the website to D2 while rewriting the docs. The Docusaurus team could help with that. |
@yangshun : yep, I figure we can migrate RSK -> RR -> Redux core, in that order. But, I don't want to hold up getting new content in place waiting for a revised publishing approach. We can always format stuff better later. (Or, if necessary, add some manual HTML tags to the Markdown to get formatting.) Besides, this is probably one of the first pages I want to put together. |
I love this. One thing that I personally would add to the "Evaluate each piece of state to determine whether it should live in Redux or not", but don't really know your opinion on: API Cache state. Personally, I believe that in most cases this should not be handled by redux, as it will people start at zero/almost at zero every time, leaving them with problems like
Honestly, I haven't seen one implementation in the wild that does all of those right. Either we should be able to recommend a good middleware for that (if there is one I don't know it), or a few libraries that live outside of the redux space (as for most people, those will suffice and leave redux for the business logic). What's your take on this? |
@phryneas : I definitely don't want to address that kind of topic in the style guide page. It may be worth discussing it in a separate page under the "Real World Usage" category, but tbh those topics are pretty well out of my area of expertise. |
Good call. It's loosely related to the form-advice, so I was a bit triggered there, but it shouldn't be in a "best practice" style guide I guess. |
Sure. Added another task entry to #3598 for a "Data Fetching and Caching" page. If you'd like, go ahead and create an issue specifically to start planning the contents for that page. |
I've put up an initial outline for the "Style Guide" page. For now, I'm keeping it as one single page, but I'm totally open to splitting it up into multiple sections somehow. I've also got the recommendations grouped by priority (same as Vue), but could see good arguments for grouping them by concept somehow (especially if the list was split into pages by priority). I also borrowed the "flair"-type styling from the Vue docs page for marking each rule header as "ESSENTIAL", "STRONGLY RECOMMENDED", or "RECMMENDED". Next step is to actually fill out the contents of each rule entry. I'm interested in feedback on the list of topics and recommendations, the content (once it's written), and the structure. |
It's a great idea to put this together but also a challenging one. Thanks for undertaking it anyway :) I'm not sure if this is the correct place for this kind of detailed discussion but let's try anyway.
I think we should distinguish two things: normalizing data and having a single source of truth. We don't need to have the first one to fulfil the second one and the latter is much more important. I saw quite a bit redux apps that became unnecessarly complex just because they tried to normalize the whole state (especially the one from the server) when they would have been fine with the more colocated state which is much easier to keep consistent during updates (and with Immer we don't have issues with updating it in an immutable way) and easier to select/read (we don't need complex selector to glue together many pieces of data). What we should strive for is to split our state into aggregates what is my next point :)
I think when we talk about
For me, it is more like an optimization than good practice. Connecting components to redux come with a great cost. We sacrifice reusability, testability and readability. Redux is sill a global state and the less we tangle our app with it the better. Clear boundaries between what is connected and what not are really helpful when come to understanding how data flows through our app. |
@wand3r : thanks, appreciate the feedback. I'll agree that with Immer it's a lot easier to update nested state than it used to be. But, there's still benefits for keeping more state normalized, especially when the UI tries to read that data (particularly being able to easily extract a single item from the state based on its ID). I'm very hesitant to introduce any "new" terminology that isn't already being used with Redux. As it is, the "slice" term is something we sort of came up with ourselves, but it's been in the docs for a while. I get what you're saying about similarities with terms from outside of Redux, but given that there's already a ton of terms in the docs, I'd rather avoid throwing any more terminology in there. As for the "connect many components" thing, it's a tradeoff. The early docs suggested you should only connect once at the root of your app, but at that point you're forcing the entire app to re-render on every update, which kills perf. If you use |
Aaaaand we're live! https://redux.js.org/style-guide/style-guide I made some initial progress on the outline and the first couple entries over the weekend, and was able to crank out the rest of it tonight. We can always make further edits down the road, but this should hopefully be a valuable addition to the docs. |
This is a tracking issue to cover all work related to adding a new "Style Guide" page / section.
Tasks
The text was updated successfully, but these errors were encountered: