Giter Site home page Giter Site logo

Comments (5)

buckyroberts avatar buckyroberts commented on July 24, 2024

Yep, nice catch. Thanks!

e60e963

from react-redux-boilerplate.

Rinosh avatar Rinosh commented on July 24, 2024

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!

from react-redux-boilerplate.

buckyroberts avatar buckyroberts commented on July 24, 2024

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

from react-redux-boilerplate.

Rinosh avatar Rinosh commented on July 24, 2024

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?

from react-redux-boilerplate.

buckyroberts avatar buckyroberts commented on July 24, 2024

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

from react-redux-boilerplate.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.