3 ms·
What sort of issues are you running into as far as "how an app using Redux works"? For myself, the first thing I usually do when looking at an unfamiliar Redux
by acemarke 9y ago
What sort of issues are you running into as far as "how an app using Redux works"? For myself, the first thing I usually do when looking at an unfamiliar Redux codebase is to look at the store creation logic, see what middleware packages are being used, and see where the root reducer logic is being imported from. Then, I skim through the reducers to get an understanding of what the state structure is, what kinds of values are being stored, and what some of the reducer operations are.
I'm not sure why you say that "you need 10 packages to load JSON data". Assuming that you're in a browser that supports the Fetch API, you need _no_ additional packages at all. You can make an AJAX call in a connected component, and call `this.props.dispatch({type : "DATA_LOADED", payload : response.data})` in the success handler.
Now, we do encourage people to try moving that logic out of components to make it more reusable, which usually means using thunks. However, redux-thunk is all of 12-ish lines long, and if you'd prefer not to actually add it as a separate package, it can easily be pasted into your app directly. But, you genuinely shouldn't _need_ more packages than that to be making AJAX calls. There's plenty of additional abstractions that are available around making network requests and processing the results, but those are all purely optional.
- strken 9y agoSorry, I was a bit ambiguous and whiny in that post. What I mean is that there's a paradox of choice when trying to work out what best practices for Redux are, after running through the docs but before building something. When there are five good solutions to a problem, and none are canonical, it takes five times as long to choose one.
- acemarke 9y agoYeah, as with React, we've tried to leave the choices up to the community. This is great for some people who prefer to make choices, but not as good for others who want to be given a direction to follow. Besides the other "discussion about abstraction" issue I just linked in another comment, I also recently opened up issues to discuss general docs improvements [0] and a rework of the "Ecosystem" page [1]. I really would like to have some docs sections that give more opinionated advice for topics such as "what side effects lib do I use?". Unfortunately, my own free time is already very limited, but I would _love_ to work with people from the community to add new docs sections and update the existing ones. I also agree that there's a bit of a gap between the "TodoMVC" level and the "building a full-blown production app in the real world" level, in terms of docs and advice. I'd love to see some new docs sections that help with that aspect as well. So, genuine request to you, and any other readers/Redux users out there: if you are interested in helping improve the Redux docs, PLEASE let me know! Ping me on Twitter or Reactiflux, file an issue, or leave a comment on an existing issue, and we can figure out how you can help us make the docs better and make it easier for people to level up along their Redux journey. [0] https://github.com/reactjs/redux/issues/2590 https://github.com/reactjs/redux/issues/2590 [1] https://github.com/reactjs/redux/issues/2588 https://github.com/reactjs/redux/issues/2588