question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Immutable react-router-redux

See original GitHub issue

We use combineReducers from redux-immutable which isn’t playing nicely with the latest v5 alpha of react-router-redux.

I was hoping to be able to just let the router slice of the state tree stay as a plain JS object seeing as all interactions with it will be via react-router-redux and there aren’t any performance gains from using immutable props without refactoring all the components but that doesn’t work.

The problem occurs where the reducer uses Object.assign to merge the new location payload with the state. I get One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? ....

Anyway, it would be great if you could import an immutable reducer and selectors e.g.

import { routerReducer } from 'react-router-redux/immutable'

I forked the repo here and added the above exports which allowed me to do:

import { routerReducerImmutable } from 'react-router-redux'

This appeared to work at first and I was able to dispatch the LOCATION_CHANGE actions using the push() action creator. However this was using npm link and when I moved the code into it’s own repo on github (which I had to do because it is nested in packages), my app crashes on push. It’s really hard to work out why, the CALL_HISTORY_METHOD appears to hit the middleware but it doesn’t hit an error, just crashes. This is react-native app by the way.

Anyway, are there any plans to add this? I will try to get my fork working and tidied up for a pull request but thought it was worth raising an issue to see if there is much support for this feature and whether I can get any help with it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
bristoljoncommented, Oct 11, 2017

Also, it looks like the old instructions don’t apply. There is no syncHistoryWithStore or selectLocationState option to provide your own selector. Neither string occurs anywhere in my node_modules. Although, looking at the source, nothing actually uses store.location anyway so I guess just providing your own immutable reducer is enough but that kind of leads me back to the point above… If the store can’t be relied on as a source of truth, what’s the point of react-router-redux?

0reactions
bristoljoncommented, Oct 12, 2017

I’m not sure about previous versions but appears that this one doesn’t use the state.routing data at all. It only keeps it updated with the history state and provides a mechanism to update both by dispatching actions. Essentially the history (memoryHistory, browserHistory or whatever) is the source of truth so there is no need to provide a selector and it’s up to you what your reducer does with LOCATION_CHANGE actions

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Request: Immutable react-router-redux · Issue #5606 · remix ...
The problem occurs where the reducer uses Object.assign to merge the new location payload with the state. I get One of the sources...
Read more >
How to use react-router-redux with immutable.js - Hashnode
1. react-router-redux usage react-router-redux is library created by React Community using for connecting react-router to redux.
Read more >
redux-plugins-immutable-react-router - npm package - Snyk
An important project maintenance signal to consider for redux-plugins-immutable-react-router is that it hasn't seen any new versions released to ...
Read more >
Immutability in JavaScript Using Redux - Toptal
React -Redux is a helper library for React and Redux that eliminates most of the hard work connecting the two. To most effectively...
Read more >
react-router-redux vs redux-immutable vs redux-observable vs ...
react -router-redux vs redux-immutable vs redux-observable vs reselect ... If you find any bugs or have a feature request, please open an issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found