-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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
FAQ updates #1785
Comments
Also this seems popular and non-obvious. |
Saw that image, and I'm only partially following what's going on there. Or rather, I see the code, I'm just not quite understanding the intent or the statement. Is the intent that you're rendering a "connected-like" component, except that the "dispatch" and "reducing" is actually just updating the parent component state? I'm also not understanding the bit about "detaching" the reducer, since there's no actual store or use of |
New possible FAQ section, or possibly design doc: "Why Redux is designed the way it is". Example topics: why |
The idea is: you don't need the redux library with the dedicated store object to implement redux architecture of |
Yeah, that's sorta what I thought I was seeing. It was the "detach" phrasing that was really throwing me, because I'm aware you can actually call |
Regarding splitting logic between action creators and reducers, I think it's worth to point out that selectors(mapStateToComponent) is another good place to handle these(validation, data transform). This creates nice separation between true source from server (reducer) and view-related data that is computed (transformed or filtered) by source (selector). Another question I see often is how to make a redux module(action creators, reducers, components) that can be reused externally. Mainly how to avoid action name clashing when we have multiple module with same type in the same page, and how to determine reducer name so it can be used by createStore. |
Yeah, we definitely need a "Design Decisions" section of the FAQ. |
Question for @reactjs/redux : I'm debating potentially splitting the FAQ up into separate pages per topic. The current single page is pretty long. Any opinions? |
I do like having a list of links to all the questions on the Table of Contents. If we keep that I can't see that there are any downsides to splitting the topics onto different pages. |
Yeah, I'd definitely keep FAQ.html to have the complete TOC, and then probably have a separate TOC within each page for just its entries. |
The best way to organize them is probably whatever would produce the best results for someone doing a google search for a relevant question. |
Starting in on this task. Plan is to go ahead and split it up based on the current categories, then update the existing questions, and finally write the new material. |
I would like to know more about store enhancers. And injectable reducers for code splitting. The examples of both are quite limited and difficult to follow. |
@Medros : Hmm. Both interesting topics, but maybe not so much "Frequently Asked Questions". There was a good discussion about store enhancers on Twitter a few weeks ago: https://twitter.com/acemarke/status/778813095221170176 . Basically, they're semi-deliberately not called out in the docs right now since they're very much a power user feature, and there's some work in progress to change the internals related to them. The discussion at #1813 talks about them some, and the relevant rework issue is #1702 . For injectable reducers, you might want to look at how https://github.com/mxstbr/react-boilerplate and https://github.com/davezuko/react-redux-starter-kit do things. There's also a variety of libraries related to component state and reducer management in my Redux addons list that may be relevant. |
Good progress today. Split up the FAQ into separate pages per category, did about half of the planned updates to existing questions. I'll try to knock the rest out tomorrow. |
And the "split+update" part is now in (see #2009 ). I've got a few other things I'd like to do before tackling the new questions, so I'll leave this open for now. Probably come back to this in a couple weeks. |
Happy to help write some of these up for you. Any thoughts on the best place to start? |
Hiya, and thanks! In terms of how frequently stuff is actually asked, adding a new "Design Decisions" category would be most relevant. That said, that also jumps right into some fairly technical aspects. An easier place to start might be adding a few new questions to the "General" section. The ideas I have listed at the moment are "When should I use Redux?", "What are the pros and cons of using Redux?", and "How does Redux compare to [Angular/Backbone/MobX]?". That said, if there's a particular question that catches your eye, that works too. There's no particular deadline we're trying to hit, just a bunch of questions I've seen that I'd like to actually have covered in the FAQ. I'm happy to work with you on what direction these answers should go, editing, and links to further info, I'm just primarily focused on writing a blog post series at the moment and trying to write the FAQ stuff myself is on the back burner for me until that's done. |
OK, that sounds good. Why don't I start with When/why to use Redux and Redux state vs React state. Do you want me to write a draft and add a new PR for you to review, or do you have some other process you prefer to use? |
Ah... sorry, let me clarify what that first comment is trying to lay out. My goal was to add additional links and info to existing questions, and then write new questions+answers. I've already finished everything under the "Updates to existing questions" heading, ie, the "add new links" part. It's the "write new questions+answers" part that I'm looking for help with at the moment. The list of potential new questions is under the "New Topics" heading (starting with "When should I learn Redux?"). Anything listed under that section would be worth tackling. As for workflow: you'd want to fork the Redux repo, create a branch, and start working on your drafts. Could probably post a link to the WIP file(s) here first, and then once you think you have a draft ready, file a PR. |
OK, I'll start with Do I have to use Immutable.js?. I've just finished writing a series of tutorials on Immutable, and I use it daily, so I'm very familiar with the issues surrounding its use. |
Sounds good! The linked comment on Reddit is my own thoughts about some of the tradeoffs. I also just added pointers to the relevant sections of my React/Redux links list, on immutable data and React perf, as additional resources. The "Immutable.js" question probably belongs in a new category, but not sure what that category should be at the moment. Maybe create an "Immutable Data" category for the moment in your branch, and start writing in that page? |
@markerikson First PR is now ready for review: #2120 |
@markerikson I'm interested in working on this. Is it okay if I take the "Why use action creators?" item. Happy to start elsewhere if that is better for you. |
@maxhallinan : yep, that'd be great! Go ahead and put together a draft for a new FAQ question, file a PR, and we can tweak it there. Thanks! |
@markerikson I am interested too, Is there something in your mind I can start with, which is also commonly required by the community? |
@markerikson I made a PR for the FAQ section on design decisions #2528 |
@sbakkila : Great, thanks! I'll try to look at it tomorrow night or Wednesday. @Fyre91 : sorry for not getting back to you faster. Anything up there in that list that hasn't been mentioned in the last few comments is fair game :) If you want a couple suggestions to start with, you could work on the "Updates to Existing Questions" items I have listed for the "one state tree" and "multiple dispatches" questions. |
@markerikson I'm sorry this took so long. I've opened PR #2535 for "Why should I use action creators?" |
I also opened PR #2537 to add links to the Actions FAQ section. FWIW, the other links that are listed for update in this issue description seem to be added already. Otherwise, I would have included them with this PR. |
I was thinking of moving on to "When should I learn Redux?" Is this question specifically with regards to React? Otherwise, it seems that you should learn Redux when you should use Redux, which would overlap with the already answered "When should I use Redux?". |
@maxhallinan : Eh, it's sort of in regards to React. And yeah, there's some overlap with "When should I use Redux?", but I think it's distinct enough to warrant its own FAQ entry. |
@markerikson OK i will take up one state tree performance FAQ. |
@Fyre91 : cool, thanks! |
@markerikson Ok, sounds good. I'm taking "When should I learn Redux?". |
@markerikson I'm going to take 'Why use React-Redux' next. |
@markerikson I'm taking the pagination/caching item under Performance next. Just to confirm, the actual question is "Can I cache paginated data without causing memory problems?" |
@maxhallinan : roughly, yeah. The other trains of thought were maybe things like "How do I implement cache checks?", "How do I handle clearing cached data?", "How much can I safely cache in memory?", etc. To be honest I don't remember exactly what I was thinking when I wrote that item, but that's what those links cover. I also just added a link to a great post on tracking subsets of normalized data. This could easily turn into multiple separate question entries if we feel like it needs it, and I'm not as sure exactly what I want to see out of it. Take a stab at the topic, see what you come up with, and we'll work from there. |
I just updated the list at the top of the thread to reflect what's been worked on recently. (Actually, y'know... I really shoulda made it a checkbox todo list from the start, instead of cutting and pasting completed stuff into a second section. Oh well.) Great to see the list of stuff remaining getting smaller! |
@markerikson |
@markerikson "Why use action creators?" is also in master. |
@gribnoysup , @maxhallinan : ah, yes, so they are :) Updated the list. Definitely getting there. Looks like all the updates to existing questions are done, and there's just a few new items left. |
Just came up with a new "Design Decisions" question: "Why does Redux separate out actions and updates?" |
I think we're good on this. We can track individual FAQ updates in other issues. |
Summary
I did the initial grunt work of writing the FAQ. @gaearon did some editing, I added the TOC and the short question links, and it's been a great resource so far. Since then, I know @gaearon has pointed to a number of discussions and articles as being FAQ worthy, and I have a bunch of backlogged bookmarks and updates I need to sort through. Let's try to list any topics, links, or items we feel need to be added or updated.
Update
I added the updates to existing questions, but am currently focused on other tasks. If anyone is interested in helping write the "new" entries, I'd be happy to work with them regarding info, content, and editing!
Waiting to be Added
New topics
General
Code Structure
Performance
Design Decisions
React-Redux
Other
Updates to Existing Questions
It's not an FAQ item, but I'll leave a note for myself here rather than filing a new issue. The "Beyond combineReducers" page should have a mention of "double-nesting state", as in
state.posts.posts
, usually due to initial state defining a key and the slice reducer being given a key. . Definitely a common mistake.Completed
New Topics
Immutability
Updates to existing questions
When/why to use Redux?
Redux state vs React state:
Serializable store data:
Nested data:
Actions:
File structure:
Scaling:
Multiple re-renders:
Where does business logic live?
Multiple dispatches
Why doesn't Redux pass the state to subscribers?
Why doesn't Redux use classes for actions and reducers?
Why does the middleware signature use currying?
subscribe
to middlewareAPI #922, RFC: Simplify middleware signature #1744Why does
applyMiddleware
use a closure fordispatch
?dispatch
in applyMiddleware to make it more expressive #1592combineReducers
recursion / limitations?Why doesn't
mapDispatch
allow use ofgetState
ormapState
return values?state
as the third parameter tomapDispatchToProps
react-redux#237Will having "one state tree" cause memory problems?
Why use action creators?
The text was updated successfully, but these errors were encountered: