That's a lot of questions; most of them have nothing to do with React/Redux; they're really about EcmaScript 2015/2016/next. Maybe you'd like to re-phrase your question? Anyway, here's my two cents':
Why is AppRegistry in {}, and what is the functional difference to the import of React and the import of AppRegistry?
What happens with this import-statement:
Here's a little explanation about
ES2015 imports
. Consider two files:
// A.js
export default 1;
export const two = 2;
// B.js
import one from "./A";
import { two } from "./A";
console.log(one); // 1
console.log(two); // 2
This is (roughly) executed like:
// A.js
module.exports = {
default: 1,
two: 2
};
// B.js
var one = require("./A").default;
var two = require("./A").two;
You will notice that in ES2015,
curly braces
can be used in the import statement to denote that you only want to
import a specific export, but not the whole module
.
If you omit the curly braces, you will only import the
default
export.
You can also use
asterisks
to
import all exports
(that is the default export and all other named exports) into one binding. For example,
import * as everything from "./A";
should more or less be transpiled to:
var everything = require("./A");
Now,
everything
is an object with bindings to every export as seen above.
Thus,
everything.default === 1
and
everything.two === 2
.
What will be passed to the Counter-Component?
Only
state.count
and an argument list of all
actions
.
What does the return-statement really return?
The object
{
...state,
count: state.count + 1
}
contains an
object spread property
. Assuming
state
is
{
a: 1,
b: 2
}
it will transpile to:
{
a: 1,
b: 2,
count: state.count + 1
}
Also, the project contains a simple file called index.js in the reducers folder with the following plain content […]
Does it make sense?
Importing modules just to export them
can
make sense in projects where the internals shouldn't be imported directly. I haven't had a look at this particular project, so I'm not in the right place to judge whether this makes sense in this project or not; anyway, there's a
shorter syntax for that
, too:
export { counter } from "./counter";