-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Source code is ready for review #4
Comments
hello, source code looks helpful but I wonder is there a specific reason for not using react-redux? |
It's an extra topic to teach and I'd like to minimize the number of new libraries introduced in the course. Nothing against react-redux, it's a sweet lib |
@EricSimons The pattern used in the reducers should be different. While you are utilizing This could be easily updated by returning the result of the return Object.assign({}, state,
/* etc.. */
) |
@njj fair point, will fix |
Any reason for using Maybe some destructuration could improve readability too, e.g: const Router = require('react-router');
// ...
<Router.Router history={Router.hashHistory}>
<Router.Route path="/" component={App}>
<Router.IndexRoute component={Home} />
<Router.Route path="login" component={Login} />
// ...
</Router.Route>
</Router.Router>
// ... Would become: import { Router, Route, IndexRoute, hashHistory } from 'react-router';
// ...
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path="login" component={Login} />
// ...
</Route>
</Router>
// ... |
Oh and one last thing for today: redux encourages you to provide a default value for the state within a reducer, e.g: function todos (state = [], action) {} Might be a good idea to add that too. |
Re: #4 (comment), will do. Re: destructuring, that seems to be the standard in the react community so I think it's the right way to go. |
I... would argue against that. It's taught in the Redux docs, it's used by everybody who's using React... if this is supposed to be an example of how to use Redux, and it's built using React, you ought to be demonstrating best practices there as well. |
That's a good point. We had originally wanted to show the plumbing of how React & Redux work separately, but now I'm thinking we should briefly explain what's going on under the hood of react-redux in the course and use it in the code. @markerikson what did you think of the codebase otherwise? |
Haven't had a chance to look it over yet - was just glancing at the issues list. I'll try to check it out later. |
@markerikson whatever happened to https://twitter.com/dan_abramov/status/725091443690356736 ? :) My beef is that this course already is going to have to touch on JSX, webpack, babel, react, and redux, and I'm loathe to bring in yet another concept because I don't want this course to turn into one of those ludicrous "redux is easy, all you need is these 30 packages and this 100 line webpack config file and you can make 'hello world!' appear on the screen!" blog posts. Any way we can do without it or is this a hard requirement for getting this into the redux repo? |
Whoa, whoa, hang on. I may have been given commit access to Redux, but I am in no way an official arbiter of what gets into the repo. I've added a lot to the docs, which is why Dan gave me commit access, but I've stayed away from touching any PRs that have to do with the code. But, having said that: as I understand it, the entire point of this repo is to demonstrate a full-blown, working, no-kidding, Redux-based application (per reduxjs/redux#1353). React is the most commonly used view layer for Redux, and you guys picked that. My personal opinion is that if you're going to use React with Redux, and you're not using the React-Redux package, which is the "official bindings" between the two, it is an anti-pattern. And if that's what you're teaching, you are doing your students a disservice. I've had to correct a number of people asking questions in Reactiflux#redux who were trying to effectively re-implement what I still haven't actually gone through the code in this repo, but a quick search for "store" turns up sections like Login.js#L12-L49, which appears to be importing the store reference directly, initializing component state from the store's state, and manually setting up action dispatching. Honestly, I've never seen that initialization pattern used anywhere else before. And, beyond that, the FAQ specifically advises against directly importing the store. Now yes, I did write the FAQ myself, but based on existing discussions and advice, and Dan vetted the content before accepting the PR. In contrast, I've been trying to collect some links to actual real Redux apps, and found a few more yesterday. MapStore2, Wordpress-Calypso, and Panther all appear to be very well-written applications, and all of them use So. I realize that this is a sample project you guys have put together, and that you weren't obligated to do so, and I do appreciate the work you've put into it. But, especially given that this is supposed to demonstrate a "real" application using best practices, I _strongly_ urge you to redo the UI layer to use |
Yeah I did a little more research and looks like react-redux can help clean the code up a bit. Will do, thanks for the suggestion. Any further suggestions are most welcome :) |
Yeah, that's sort of the point - the code will be shorter, less tightly coupled, and more testable. And I honestly don't think that React-Redux is that much to explain. If it helps at all, I've got a couple snippets demonstrating usage of I'll try to look over the rest of the codebase later, but not sure exactly when I'll have time. |
Dan did a great job at introducing those concepts in his egghead's serie: Getting Started With Redux. He starts by showing what the code would look like without the redux/react-redux libraries and then add them to the mix, making it way clearer. IMHO, the most complex part is the tooling so it may be a good idea to not focus on it too much. |
I know this is a bit late. But I was looking through the source code, and I was wondering why the auth token wasn't saved in redux. Storing it as part of a module is a pattern I have never seen before. |
@eliaslfox I'm pretty sure @vkarpov15 did that for separation of concerns. The only time a JWT is needed is when the app is attempting to make XHRs, so he bundled it in with the custom superagent middleware (and it gets populated on page load and/or on login+register). It's not needed for any application state, so putting it in redux wasn't necessary. |
Hey all - we're 100% source code complete and would love your feedback!
The documentation around the codebase is a little slim right now but we're working to have it done within the next few days. The codebase is pretty straightforward but if you have any questions, feel free to post them here and @vkarpov15 can answer them.
Looking forward to hearing your thoughts!
The text was updated successfully, but these errors were encountered: