Question about the react-redux documentation

43 views Asked by At

I am confused by something on the react-redux documentation

https://redux-docs.netlify.com/recipes/configuring-your-store/

specifically, in attempting to build the prototype app (which is provided here https://github.com/reduxjs/redux/tree/master/examples/todos/src), I am confused about the line

import rootReducer from './reducers'

what is confusing is that in the app directory, there is no such file reducers.js, there is only a folder reducers/ which contains

index.js
todos.js
todos.spec.js
visibilityFilter.js

I see no file for rootReducer, so I am assuming (correctly?) that the ES6 syntax for the above code is importing the default export from

reducers/index.js

is that correct?

In that file, I see


export default combineReducers({
  todos,
  visibilityFilter
})

do I understand correctly the defaulted export anonymous function, exported from reducers/index.js, is then imported into index.js as rootReducer ?

enter image description here

1

There are 1 answers

2
markerikson On BEST ANSWER

Yes. That's ES6 "default export" syntax, combined with an index.js file. When an index.js file exists in a folder, you can specify just the folder name in the import statement, and the bundler knows to look at index.js automatically.