Skip to content
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

Doubt about MD explanation #2

Closed
Rinosh opened this issue Jul 12, 2016 · 5 comments
Closed

Doubt about MD explanation #2

Rinosh opened this issue Jul 12, 2016 · 5 comments

Comments

@Rinosh
Copy link

Rinosh commented Jul 12, 2016

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 😋 .

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 🍅). You're awesome Sir!. Have you ever wanted to try Golang btw? I sincerely think that you might shine over there. Saludos!

@buckyroberts
Copy link
Owner

Yep, nice catch. Thanks!

e60e963

@Rinosh
Copy link
Author

Rinosh commented Jul 12, 2016

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
Copy link
Owner

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:

  • actions are announcements
  • reducers listen for these announcements, and then can change data/do anything else as a result

@Rinosh
Copy link
Author

Rinosh commented Jul 12, 2016

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants