Rethinking Redux

These days, I’m experimenting with Redux and some patterns because we are looking to re-architecture one of our app at Kadira.

So, I did some experiments and I didn’t like some parts like the use of the React Router. (not something wrong with it). Therefore, I had to work on simple router. I also need to build some utilities to manage data loading.

Here’s my thoughts and the sample app.

See: Rethinking Redux

Looking for some comments. Basically, I wanted to see whether this is the correct way or not.

/cc @SkinnyGeek1010


I really like this! I’m using Redux-Router in a new project and it’s very complex for what it does. I really like how your solution is even more simple.

I don’t know if I like the {layout.content === "postList"? <PostList /> : null} part. Does this get really gnarly in a large app? Although it seems like it would at least be limited to the layout which isn’t so bad.

I haven’t fully wrapped my head around loadData yet but it looks really interesting!

I’ll checkout this in more detail later tonight

Yeah! I get it.

{layout.content === "postList"? <PostList /> : null}

That’s ugly. I tried to work on a component which does something like this. But later realized, why don’t we try this. It works and I don’t think it has a performance issues too.

Give it a try :slight_smile:

1 Like

I gave it a try with the simple-redux-router. It’s very close to the Redux way and working with React Router.

I like the way, how it works.

Anyway, React Router does not support hot-reloading. But my version of this simple router does. Anyway, I don’t think react hot-reloading works with Meteor 1.3. So, that’s fine with me :slight_smile:

Here’s the code:

I haven’t heard this before. Also, I’ve got a Meteor app (early stage) using redux, react-router & simple-redux-router and hot-reload is working.

The app was originally based on ReactiveStack/Kickstarter (a lot of it has been changed out) but the Webpack config remains and it does do hot-reload, well most of the time :smiley:

I’d also be curious to hear more of your opinions on Relay and React Router. So far I like what I’m seeing on them, but I’m sure you’ve gone deeper on them than I have at this point.

About the issue. I’m seeing this on the console.

And here’s a comment from the React Router reactiflux channel.

May be I’m doing something wrong.

Router is just a tiny piece in any app. So, I don’t care much about it.
Relay is nice for getting data from remotely. But in a real app, we have more data in the UI.

That’s why I’m thinking as a Redux as a good state manager for the UI. We can Meteor, GraphQL or something else with it. I’m quite not sure about the Relay integration with Redux.

I am thinking in terms of keeping Redux and Relay as separate (side by side) state containers, letting Redux handle all state that is local to the client, and using Relay/GraphQL as the database api/cache.

Relay seems to apply a fairly Flux-like pattern to persistent data, but (as you mentioned) has no facility for local/transient state, so Redux for that. Since Relay has the ability to flow its state changes down the component tree in way similar to Redux, actually pushing the changes from Relay into Redux so that Redux can do the state updates, feels kind of redundant.

I haven’t tried any of this yet, but I’m clearly not the first to consider it:

:sunglasses: Nice!

Yes. They can live side by side.
And in the next year, relay will have local state management in the client. But that’s not a top priority.

Anyway, I am seeing some ways to use GraphQL without relay.