Closed Bug 1260864 Opened 8 years ago Closed 8 years ago

Add docs on getting data from Redux stores

Categories

(DevTools :: Shared Components, defect)

defect
Not set
normal

Tracking

(firefox48 fixed)

RESOLVED FIXED
Firefox 48
Tracking Status
firefox48 --- fixed

People

(Reporter: linclark, Assigned: linclark)

Details

Attachments

(1 file, 1 obsolete file)

      No description provided.
Attached patch Bug1260864-redux-docs.patch (obsolete) — Splinter Review
Happy to discuss and change. It has a few implicit recommendations in there, so lmk if you have any questions.
Assignee: nobody → lclark
Status: NEW → ASSIGNED
Attachment #8736444 - Flags: review?(jlong)
Comment on attachment 8736444 [details] [diff] [review]
Bug1260864-redux-docs.patch

Review of attachment 8736444 [details] [diff] [review]:
-----------------------------------------------------------------

This looks generally good to me, a few comments:

1. For simple connections, I like just specifying the selector inline:

connect(
  state => ({ items: state.items })
)(Component);

I don't think we should be too prescriptive about this, so you could make a quick not that you can do simple selectors inline? Unless you think we should be consistent, that's fine.

2. It would be good to make a quick note that the selector also takes `props` as the second argument if you need it. That's good for parameterizing the connection.

3. Might also be good to note that the second argument to `connect` allows you to hook up action creators.

4. Add a link to the react-redux docs about connect

For #2 and #3, you can be a light on details as you want. Maybe even just one sentence saying those things are possible, and refer them to the react-redux docs to see the docs.
Thanks for the review!

I think the fact that you can specify a selector in line can be left implicit and up to the discretion of the coder and reviewer. If we make it explicit here, then in other docs for things you can do either way we'd also have to make it explicit.

Good idea to add the other parameters. I've included the note.
Attachment #8736444 - Attachment is obsolete: true
Attachment #8736444 - Flags: review?(jlong)
Attachment #8737203 - Flags: review?(jlong)
Comment on attachment 8737203 [details] [diff] [review]
Bug1260864-redux-docs.patch

Review of attachment 8737203 [details] [diff] [review]:
-----------------------------------------------------------------

Sure, but people will end up just copying what's in the docs (re `mapStateToProps`). Here it's not really needed for such a simple selector. I don't think we need to explain it everywhere but if we're documenting `connect` it's the place to put it.

It's not a big deal though. These docs will change as we write more, and there's obviously a bunch more redux-specific things to write so this will evolve. This is good as is and you can go ahead and land it.
Attachment #8737203 - Flags: review?(jlong) → review+
Sounds good, thanks for the review.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/67bf00c5ecda
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 48
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: