GithubHelp home page GithubHelp logo

Comments (7)

zavelevsky avatar zavelevsky commented on April 25, 2024

Although I find redux-simple-router to be very elegant - I dislike the fact that it prevents you from using immutablejs Map as your state. That's because of this line:
https://github.com/rackt/redux-simple-router/blob/master/src/index.js#L43

Once you let libraries like redux-(simple-)router manipulate your state you have to make your state a simple JS object. If you choose to use Immutablejs for the benefits of strict immutability - you need to wrap it with an object - and it's truly annoying.

from react-boilerplate.

mxstbr avatar mxstbr commented on April 25, 2024

I'm not currently using Immutable JS because I'm not sure why I should include it. What are the benefits?

from react-boilerplate.

zavelevsky avatar zavelevsky commented on April 25, 2024

I wanted a way to prevent state manipulation - and the subtle bugs that follow. For example - if during shouldComponentUpdate you compare your previous state to the new state - you'll always get equality because it's the same instance.
This sort of "defensive" design is sometimes necessary when working with a team.

Also, using an API such as ImmutableJS' makes you stop and think of things like 1. where do you perform the state manipulation (you don't want to start importing immutablejs everywhere) and 2. what's the cost of the manipulation (copying huge collections much?).

Lastly - some strong functionality out of the box (things you'll usually use lodash for).

I'm not saying you should use ImmutalbeJS - but take into account that enough projects use it for it to be a consideration.

from react-boilerplate.

mxstbr avatar mxstbr commented on April 25, 2024

I see what you mean. And how does the Object.assign in redux-simple-router interfere with that?

from react-boilerplate.

zavelevsky avatar zavelevsky commented on April 25, 2024

Short answer: Object.assign returns an object - not an Immutable.Map. So you have a Map as your state and after their reducer is called you suddenly have a simple object.

The idea behind redux-simple-router (and also redux-router) is to take your state object and add their own subtree for routing state. But they assume your root state instance is of an object type. They can simply change it by allowing you to provide a custom reducer - and I opened a bug.

from react-boilerplate.

mxstbr avatar mxstbr commented on April 25, 2024

Ah I see, thanks very much for the info, I didn't consider that at all!

I won't be including redux-simple-router then, lets revisit this when reactjs/react-router-redux#140 is added!

from react-boilerplate.

lock avatar lock commented on April 25, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from react-boilerplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.