Closed markerikson closed 8 years ago
This would make a great top-level doc entry. I'm happy to collaborate on this if you take the initiative and gather the common questions.
Here is a resource which starts out a bit negative but has practical advice (for example, use that insight to improve your site’s content) and links to more.
http://alistapart.com/article/infrequently-asked-questions-of-faqs
@pedrottimark , thanks for the pointer.
Throwing together a scratch list of initial possible questions / topics as I skim through the issues list and SO questions:
connect
my top-level component? (yes, React-Redux specific, but relevant)combineReducers
?Related "docs"-tagged issues and assorted discussions:
That's a quick first cut. @gaearon , you've obviously been answering a lot more questions about Redux for longer than anyone else. Any suggestions for topics you'd like to have some centralized answers covered?
In general, a lot of questions seem to be about structuring reducers and areas of responsibility (Redux state vs component state, logic in actions vs logic in reducers). Also storing non-primitives/objects in the state. I know that the "combineReducers" doc page talks about structuring reducers, but perhaps there ought to be a more comprehensive page on that topic?
Lots of questions are answered in the docs but I guess it's still good to have a short question--short answer section with links to articles/sections of the docs/discussions. Few more possible Q&As (draft stage):
Some other things that we can transform into questions if necessary:
normalizr
, lodash/keyBy
, might be enough for simple projects if all we need is to transform an array returned from the server into a map id => item
: products: keyBy(products, '_id')
More ideas:
This is a great idea. Other points you might consider:
I'm only just starting out with redux, but if I can be of any help putting these together, even if it's only answering "are these answers non-expert friendly", then I'll be happy to help.
Few questions I recently answered:
Thanks for the links. I'm hoping to have some time to throw together a first draft sometime this week.
Here's an initial draft outline for the FAQ page:
The intent would be to give a reasonably short answer to each question, along with links to further reading. I would also want to write up a full page on structuring reducers, since that seems to be a topic worth a lot more detail.
Would appreciate suggestions, comments, critiques on this list.
Wow awesome list :+1:
Tiny note from me:
Actions Why should "type" be a string, or at least serializable?
I think the whole action objects should be serializable, not just "type".
And there is one more question: if a middleware requires "name", not "type", what should I do? I have this in mind: https://github.com/gajus/redux-convention
Great stuff :+1:
I will take a thumbs-up from @gaearon as the signal to go ahead :)
I'll start trying to put this together. Progress will be over at https://github.com/markerikson/redux/tree/create-faq-page .
Okay, semi-related issue. Cloned my fork, npm install
, npm run docs:prepare
, Gitbook installed. Ran npm run docs:build
, and got an error:
Template render error: (D:\Projects\redux\docs\basics\ExampleTodoList.md) [Line 143, Column 21]
expected variable end (In file "docs/basics/ExampleTodoList.md")
Looking at it, it's a code sample that's doing inline styles, and thus has a style={{someObject}}
chunk in it. Adding spaces between the curly braces fixed it. Also had the same error in UsageWithReact.md line 123. Fixing both of those allowed Gitbook to build the docs correctly.
Any particular reason why this hasn't noticed and fixed already by someone else? I'd expect it to actually have blocked major edits to the docs.
Argh. Um. One more question: the CONTRIBUTING page says to use typography stuff like smart quotes. I'm trying to follow suit and do so, but the result isn't coming out well. The resulting HTML is coming out as everyone's favorite Unicode diamond question mark characters instead. I've tried copying and pasting the smart quote characters from CONTRIBUTING.md, typing them in manually (I'm on Windows, so ALT+0147/0148), etc. They actually seem to render okay over at http://jbt.github.io/markdown-editor , but not in Gitbook's output. Is there some trick I'm missing to this?
Looking at it, it's a code sample that's doing inline styles, and thus has a style={{someObject}} chunk in it. Adding spaces between the curly braces fixed it. Also had the same error in UsageWithReact.md line 123. Fixing both of those allowed Gitbook to build the docs correctly.
Interesting. Maybe a regression in Gitbook?
I am using Gitbook 2.4.3 (specified in book.json
). I have plugins resolved like this:
info: install plugin edit-link from npm (gitbook-plugin-edit-link) with version 1.4.2
info: >> plugin edit-link installed with success
info: No version specified, resolve plugin prism
info: install plugin prism from npm (gitbook-plugin-prism) with version 1.0.0
info: >> plugin prism installed with success
info: No version specified, resolve plugin github
info: install plugin github from npm (gitbook-plugin-github) with version 1.1.0
info: >> plugin github installed with success
Any particular reason why this hasn't noticed and fixed already by someone else? I'd expect it to actually have blocked major edits to the docs.
Can’t reproduce it.
The resulting HTML is coming out as everyone's favorite Unicode diamond question mark characters instead.
Do you have the same problem on the current docs website?
Yeah, NPM installed Gitbook 2.4.3 here as well.
Looking at redux.js.org, smart quotes render okay in my browser. Looking at the fresh build on my local box, smart quotes render okay in pages such as "Prior Art", but not in the FAQ page I was creating myself. Clearly there's something different about how I'm trying to use them. I'll try this again tonight.
For now, just do as you find convenient (i.e. you can work on FAQ from Github interface, not use smart qoutes, etc). We’ll prettify before merging.
@markerikson this is a great list :clap:
Actions Why should "type" be a string, or at least serializable?
I think the whole action objects should be serializable, not just "type".
In the answer we might want to note that an action could be unserializable initially, but should be serializable eventually after it's gone through a middleware chain.
More questions to consider:
next
and dispatch
inside a middleware?real-world
example and erikras/multireducer
? Factories are more flexible because it's possible to create different action types for every new reducer?Got my initial progress over at https://github.com/markerikson/redux/blob/create-faq-page/docs/FAQ.md . Actual feedback on the content so far would be appreciated :)
@Dattaya : yeah, a couple of items on middleware might be useful also. As for the reducers, that stuff would go into the "Structuring Reducers" page I'm hoping to add as part of this rather than directly into the FAQ list itself.
Been busy the last couple nights, so the pace has slowed down to one or two answers written up per evening. But, making progress - 11 questions down, 14 to go at the moment.
How to reset the state of a Redux store:
@gaearon , I'd kinda skimmed past your "action in timeout" and "multiple dispatch" answers previously, but just had a chance to look at them again. No kidding, those deserve to be a new docs page right there.
I also think there is a lot of questions about authentication with redux, the most frequent ones I tend to note on twitter or github issues are "How to authenticate with JWT and Redux?"
You may have already pointed this out but I skimmed over the comments.
I've certainly seen a few questions to that effect, but on the flip side, I'm really not sure that's actually a Redux-specific question.
Just bringing it up because I see it asked alot and this is a FAQ 😅
Just bringing it up because I see it asked alot and this is a FAQ 😅
Agreed. Here’s a good article: https://auth0.com/blog/2016/01/04/secure-your-react-and-redux-app-with-jwt-authentication/
Sure, valid point, and I have asked for feedback :) I'm not entirely against putting that into the FAQ, but at the moment I would say it's less of a priority because it's not concerned with core Redux behavior. It's also a topic I'm not nearly as familiar with myself. If you or someone else had time to write it up, though, I'd totally take it as a PR against the branch I'm working on in my fork.
I would love to help out and do that. Can you make the initial FAQ so I can structure what I put so that it matches with what you are going to write up?
Yep. Re-pasting the link, the current WIP is at https://github.com/markerikson/redux/blob/create-faq-page/docs/FAQ.md . Basic format is a couple paragraphs explaining the answer in general, followed by 3-4 links to relevant Redux docs, issues, SO questions, or other relevant articles.
Okay I'll get to it.
@markerikson Made some changes you should have received a notification.
Difference between Backbone and Redux: https://news.ycombinator.com/item?id=11187727
Yeah, could maybe toss that in along with a "When should I use Redux?" question.
Doing some traveling tomorrow. Will see if I can crank out a few more answers during the trip.
Doing some traveling tomorrow.
I read that as “doing some time traveling tomorrow”. :joy:
Well, given that I'm crossing a couple time zones, that's not entirely inaccurate... :)
This is probably already in the FAQ but I wrote again about combineReducers()
: http://stackoverflow.com/a/35674297/458193
How to dispatch different actions depending on the route? http://stackoverflow.com/questions/35665724/with-react-redux-router-how-should-i-access-the-state-of-the-route/35674710#35674710
Still cranking away on this. Got to 14 of 26 questions answered as of this evening, but then added two more to be answered ("When should I use Redux?" and "How many components should I connect?").
If anyone else would like to chip in, PRs still totally welcome :)
Getting there. Spent most of the day on this, and I'm up to 23 of 29 questions complete. Might actually get the initial writeup completed within the next day or two.
And there we go - all current 29 questions in the outline have answers written up.
Can I get some feedback on the current writeup before I submit a PR?
PR is an easier way to get feedback :wink: Great job.
Sure. In the interest of keeping the history a bit cleaner, I'll try creating a second branch that has the content, but only one commit (unless you'd rather I just submit the PR as-is)
No big deal about it, do anyhow you like. We barely make any source changes at this point so we don’t care much about clean history.
Heh. Well, it's up - #1489.
Related observation: it'd be nice to be able to link directly to certain questions once this is published in the docs. I know you can link to headings in Github Markdown, and Github provides those nice on-hover anchor icons to be able to copy the relative links. I see that Gitbook does add ID tags to headers, such as "#is-there-always-a-1-1-mapping-between-reducers-and-actions", but there's no easy way to copy that. Would adding something like https://github.com/rlmv/gitbook-plugin-anchors to Redux's Gitbook setup be a good idea?
@markerikson, you are doing a great job! I've found a lot of answers and useful links in your FAQ.
So. The core FAQ page is finally published. Per my last comment, it'd be nice if we could get easily-copyable anchors or shortcuts or something. Also up for discussion of further edits and improvements, like adding a ToC or splitting it up into sub-pages.
Thoughts/suggestions?
I've noticed a LOT of FAQs appearing in Reactiflux, SO, the issues list, etc. Stuff like "sharing state between reducer branches", and "any good-sized Redux examples?", and so on. Is there a good place to create an FAQ list for Redux? Should there be a new page in the docs folder? Add a wiki to this repo? Create a separate repo? I can always go create my own FAQ repo, but figure it's probably worth coordinating with everyone else on this.