Live data from Hacker News

Django React/Redux Base Project

github.com

61–70 of 79 posts

Re: Django React/Redux Base Project

#61
post #58
post #51

Earlier quoted context omitted.

> the way it integrates with React never feels natural Could you elaborate on that? In my opinion Redux reinforces that the majority of your app should effectively be (props) => JSX (even if they're es6 classes, they're still just rendering props). Alternatively I feel like it'd be relatively easy to do non-Reactish things with MobX since more of your components are aware of it.

> Redux reinforces that the majority of your app should effectively be (props) => JSX Sure, Redux strongly recommends that practise - and it's a good one - but nothing about it is specific to redux. You can factor your components in the same way with mobx, or with plain React for that matter. The point of redux and alternatives is to remove state management from inside the components to a dedicated store. Redux doesn…

In my mind there's very high value in the fact that deviating from that is _difficult_ with Redux. Not only does it keep me honest but if a junior dev jumps into my codebase it's actually work for him to do something sketchy with how he's controlling state.

Re: Django React/Redux Base Project

#62

Why is this packing together a backend tec and a frontend tec? I assume the frontend is generated from django models and views code? Or does one have to maintain frontend code manually - no that would not make sense at all. However I can not see any hint about how the frontend code gets generated?

Hey, check section "Main Project" in out README. Should be clear enough

Re: Django React/Redux Base Project

#63
post #34

I feel like the best way to do this is to just use cornice or DRF then use js scaffolding that is completely unaware of your backend. No need to join them at the hip like this, except maybe for the token based auth?

Token based auth is stateless, so your first assumption stands true -- no need to join them at the hip. I've tried working with tools like Djangular and whatnot, and no matter how many times I've tried working within that ecosystem, I've always had better results, cleaner and simpler code by keeping the UI and Backend completely separate.

Token based auth doesn't need to be stateless. In fact in our current implementation it is not.

If you use stateless like JWT (we had this before) you end up having a huge problem: imagine a user wants to logout all the open accounts in different browsers.

How would you handle that? You would need to wait for the expiration of the token, a solution that is not that secure.

Re: Django React/Redux Base Project

#64
post #55
post #51

Earlier quoted context omitted.

> the way it integrates with React never feels natural Could you elaborate on that? In my opinion Redux reinforces that the majority of your app should effectively be (props) => JSX (even if they're es6 classes, they're still just rendering props). Alternatively I feel like it'd be relatively easy to do non-Reactish things with MobX since more of your components are aware of it.

Not the parent, but when I was trying to learn R+R I kept getting confused by what they meant by 'state'. React state belongs to some component (whichever can mutate it) and is passed to children via props, and generally seems to include a mixture of view state and data/model state, with view-state originating somewhere in the component hierarchy while model state comes from the root. Redux's tutorial implied to me t…

React allows you to keep state in components, but that doesn't mean that you should. When you're using React + Redux, keeping ANY state in components is an antipattern. Keeping all state in the "root" (the redux store) allows you to observe the your app's complete state in one place, all previous states, and the exact sequence of events that triggered all past state transitions. This discipline enables features like time-travel debugging, where you can rewind or fast-forward through your app's states one event at a time.

Re: Django React/Redux Base Project

#65

So for people who think they need Redux, first read "You Might Not Need Redux" [0] by Dan Abramov himself, creator of Redux. Then also I would recommend MobX [1] over Redux, it's easier to get started and in my opinion easier and better in general. [0] https://medium.com/@dan_abramov/you-might-not-need-redux-be4... [1] https://github.com/mobxjs/mobx

I used both Redux and MobX. I can't recommend MobX enough. Redux is just way too much boilerplate code and has a steep learning curve.

Also MobX + TypeScript is just beyond awesome! You don't want to do MobX without TypeScript if you have the chance.

Re: Django React/Redux Base Project

#66
post #50

Earlier quoted context omitted.

You can easily maintain the abstraction of dumb components if you wish to: const TodoView = ({title, isFinished, onClick}) => ( {title} ) const TodoViewContainer = observer({todo} => ( todo.finished = !todo.finished} /> )) But how often are you changing your app's data layer? Is the tradeoff _always_ worth it? Mobx allows you to be as pragmatic or dogmatic as you choose to be

> But how often are you changing your app's data layer? Is the tradeoff _always_ worth it? Yes, because in my mind that's the litmus test that your app is properly data-agnostic. And a key thing about Redux is it stays that way -- it's actually difficult to leak your data store to child components. Even if I adopt the above approach with MobX it'd be incredibly easy for some other developer to start passing around st…

I've had a presentation about this a short while ago. It's easy to do both ways with MobX. You can have smart components and dump components however you want them. You have this with Redux too, but the most standard way in Redux is to use connect() and that makes components dump anyway.

Re: Django React/Redux Base Project

#67
post #46

So for people who think they need Redux, first read "You Might Not Need Redux" [0] by Dan Abramov himself, creator of Redux. Then also I would recommend MobX [1] over Redux, it's easier to get started and in my opinion easier and better in general. [0] https://medium.com/@dan_abramov/you-might-not-need-redux-be4... [1] https://github.com/mobxjs/mobx

I'm 3 months into my first React/Redux project and wouldn't adopt Redux again if I were starting over. Don't get me wrong, it's not horrible, but it's not great either. Compared with the extreme elegance and simplicity of React itself, Redux is verbose, boilerplatery and the way it integrates with React never feels natural. I've taken a look at Mobx and had that aha moment of "yes, this is what the solution should lo…

You might also be interested in how Cx handles state and data-binding. It's a combination of ideas from Redux and Angular (immutable data store + declarative data binding) -https://cx.codaxy.com/docs/concepts/data-binding

Disclaimer: Cx is a commercial framework and I'm the author.

Re: Django React/Redux Base Project

#68

So for people who think they need Redux, first read "You Might Not Need Redux" [0] by Dan Abramov himself, creator of Redux. Then also I would recommend MobX [1] over Redux, it's easier to get started and in my opinion easier and better in general. [0] https://medium.com/@dan_abramov/you-might-not-need-redux-be4... [1] https://github.com/mobxjs/mobx

It's been less than 6 months I first heard about Redux. Looking at its issues, it seems to be a little more than 1 year old. Now everyone is talking about MobX. Why not improving Redux in first place? If it's verbose, why not writing more abstractions on top of it to make it easier to use? IMHO we should think more about those questions before writing another framework-of-the-day.

Re: Django React/Redux Base Project

#69

So for people who think they need Redux, first read "You Might Not Need Redux" [0] by Dan Abramov himself, creator of Redux. Then also I would recommend MobX [1] over Redux, it's easier to get started and in my opinion easier and better in general. [0] https://medium.com/@dan_abramov/you-might-not-need-redux-be4... [1] https://github.com/mobxjs/mobx

It's been less than 6 months I first heard about Redux. Looking at its issues, it seems to be a little more than 1 year old. Now everyone is talking about MobX. Why not improving Redux in first place? If it's verbose, why not writing more abstractions on top of it to make it easier to use? IMHO we should think more about those questions before writing another framework-of-the-day.

Mobx has been around for a while but it's just less well known due to developer relations. In my experience, Redux is great but requires a lot of work to get started, or abstractions. People have made quite a lot of open source projects to solve these issues for different use cases but it looks like Dan and other developers want to keep Redux core very simple so I would not expect any opinionated abstractions to land in the core.

Mobx on the otherhand is "batteries included" and doesn't require much extra code to get started. We're using Mobx in production and only packages we needed to install were `mobx` and `mobx-react` along with some babel extensions. Very simple and increases developer efficiency by a mile not to mention onboarding time...

Re: Django React/Redux Base Project

#70
Oh, thank you so much, this will be extremely useful for me!

I've been using Django for a long time, and I love it. And now, I've just started learning React/Redux. After some research I think that Django+React is the perfect combination.

This project is excatly what I needed to help me get started!

Post reply on HN