This course has been updated! We now recommend you take the Complete Intro to React, v7 course.

Check out a free preview of the full Complete Intro to React, v3 (feat. Redux, Router & Flow) course:
The "Q&A: Objects and Props, Dispatch, & More" Lesson is part of the full, Complete Intro to React, v3 (feat. Redux, Router & Flow) course featured in this preview video. Here's what you'd learn in this lesson:

Brian takes questions from students.

Get Unlimited Access Now

Transcript from the "Q&A: Objects and Props, Dispatch, & More" Lesson

>> Brian Holt: Go ahead.
>> Speaker 2: Quick question. What are the inputs and the outputs of mapStateToProps and mapDispatchToProps? What's sort of the overall purpose of them? I mean, what are they doing sort of the?
>> Brian Holt: They're returning objects, right? Right, this is an object.
>> Speaker 2: Okay.
>> Brian Holt: So if you want to make this a little bit more verbose, it's gonna look like this.

>> Speaker 2: And.
>> Brian Holt: Right, but this is what it actually looks like.
>> [SOUND]
>> Speaker 2: And who eventually uses that object?
>> Brian Holt: So this is the object and you remember how we did something like this right here well it's taking this object and spreading it over the component.

[00:00:53] That's precisely what's happening here to search. It's taking this object and spreading this object over search, right? So everything that I put in here is going to be passed as a prop to search. So search term is now a prop of search because of this.
>> Speaker 2: Okay.
>> Brian Holt: So if I put, blah: 5, right.

[00:01:16] Now it have inside of props I could reference props.blah and I would get 5, right. It's just passing props into search.
>> Speaker 2: Okay, great. And then the dispatch is?
>> Brian Holt: It's a function that Redux gives you to pass actions into the reducers.
>> Speaker 2: Okay.
>> Brian Holt: Does that make sense?

>> Speaker 3: Is that have use beyond wiring up event handlers usually?
>> Brian Holt: What is it?
>> Speaker 3: MapDispatchToProps. Does it have use beyond? Wearing of event handlers, no.
>> Brian Holt: Well, mapDispatchToProps. Does it have more uses than that? I mean, you can kick off a synchronous actions and we'll talk about that tomorrow, async actions.

>> Brian Holt: But it's gonna be kicking off action, that's the point of map dispatch profits. Translating events in the UI to actions into the Redux store, that's the whole purpose.
>> Speaker 4: Does the Redux state object get too complicated over time?
>> Brian Holt: I'm going to show you how to silo it tomorrow.

[00:02:37] So that despite the fact that that tree can become quite large you're only gonna be working on very small slices at a time so it keeps it pretty manageable. It can get complicated but with discipline and kind of enforcing some rules on yourself it can be fine even with giant stores.