buckyroberts / React-Redux-Boilerplate

Awesome React / Redux boilerplate and tutorial.
https://www.youtube.com/user/thenewboston
819 stars 621 forks source link

Doubt about MD explanation #2

Closed Rinosh closed 8 years ago

Rinosh commented 8 years ago

I got a doubt about your explanation on README.md inside components folder. You say that "components are aware of application state". However, I understand that containers are aware of state. Perhaps you wanted to say "components are NOT aware of application state". And this is just a bacon, tuna, typo, whatever :yum: .

Anyways, I came around here after watching some talks from Rob Pike on youtube and I really enjoy how you flow smoothly across a lot of explanations (just to make a :tomato:). You're awesome Sir!. Have you ever wanted to try Golang btw? I sincerely think that you might shine over there. Saludos!

buckyroberts commented 8 years ago

Yep, nice catch. Thanks!

https://github.com/buckyroberts/React-Redux-Boilerplate/commit/e60e9633f6b5e8784220bc649543653a416633c2

Rinosh commented 8 years ago

Sorry to bother you again with these doubts, but I keep getting caught...

I read about your explanation on "Actions vs. Action Creators" in the README.md file inside 'actions' folder and then I ended up concluding that reducer-users.js file is an action creator... am I right? or I just got confused...

Thanks in advance!

buckyroberts commented 8 years ago

No problem.

Not exactly. Action creators are the function, and actions are the return value of that function. Think of it like this:

function actionCreator() {
    return action;
}

Actions are just like announcements, they don't really do anything in terms of changing or manipulating any data in your program. They just let the reducers know that "something just happened".

A reducers job is to basically wait and listen for these announcements (actions) to occur. Once it hears one, it decides how the programs data should be changed. So basically:

Rinosh commented 8 years ago

Thank you, Sir. I'm trying to stay in the same page.

So, here comes another one: index.js inside dev/js path is going to DOM, so we find the next statement in Line 3: import ReactDOM from "react-dom";

However, after looking at real-world redux official example, I found that they call render function directly, using this statement instead: import { render } from "react-dom";

Here I found some answer:

This is by design – it’s much better and you’re encouraged to import just the functions you need to use.

Ok. I shouldn't be thinking about just merely syntax sugar, but I still wonder if we should be aware about some subtle improvements besides saving a few characters. Are we getting better performance? Saving some memory? Is it just a good practice to get more concise or cleaner code? Does it really matter to bother you with bananas and mango?

buckyroberts commented 8 years ago

Yep, that is just a different way you can import functions from external modules in ES6. It does make the code a little cleaner, you just have to watch out for naming conflict (for example if more than one module had a render() function)

If you see any areas for improvement, feel free to submit a pull request to the repo. Check this cheat sheet out too, I always refer to it when working with ES6!

nx7wjvz