Skip to content

State getter should return state when it is nested in an immutable object #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 11, 2017

Conversation

florisvink
Copy link
Contributor

@florisvink florisvink commented Apr 6, 2017

If your entire redux state in Immutable you ran into problems when nesting the grid-reducers in a separate reducerKey. The StateGetter was in the assumption that the parent object is always a plain Object. With this pull-request it is also possible nest your grid reducers in an Immutable object.

Now this works:

import { combineReducers } from 'redux-immutable';
import { Reducers } from 'react-redux-grid';

const gridReducers = combineReducers(Reducers);

const reducers = {
    app: appReducers,
    grid: gridReducers
};

const store = createStore(
    combineReducers(reducers),
    Immutable.Map(initialState),
    compose(applyMiddleware(thunk, promise))
);

...also fixed a wrongly named export in the docs

@codecov-io
Copy link

codecov-io commented Apr 6, 2017

Codecov Report

Merging #153 into master will increase coverage by 0.31%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #153      +/-   ##
==========================================
+ Coverage    76.6%   76.92%   +0.31%     
==========================================
  Files          87      112      +25     
  Lines        4287     4541     +254     
  Branches      277      277              
==========================================
+ Hits         3284     3493     +209     
- Misses        803      838      +35     
- Partials      200      210      +10
Impacted Files Coverage Δ
src/util/stateGetter.js 89.28% <100%> (+0.82%) ⬆️
src/records/components/plugins/Editor.js 80% <0%> (-12.42%) ⬇️
src/records/components/plugins/BulkAction.js 80% <0%> (-11.67%) ⬇️
src/records/components/plugins/Loader.js 80% <0%> (-11.67%) ⬇️
src/records/components/plugins/Pager.js 80% <0%> (-10.33%) ⬇️
src/components/plugins/editor/inline/Button.jsx 78.18% <0%> (-9.88%) ⬇️
src/records/components/plugins/Selection.js 80% <0%> (-8.77%) ⬇️
src/records/components/plugins/Menu.js 80% <0%> (-7.88%) ⬇️
src/records/components/plugins/ErrorHandler.js 80% <0%> (-2.36%) ⬇️
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d59375a...2c38cd7. Read the comment docs.

@bencripps
Copy link
Owner

Changes look good, I will verify tonight. Did you run this version with your local app to make sure it handles immutable state correctly?

@@ -109,15 +109,15 @@ If you want to hide grid reducers from the root of your state:

````js
import { combineReducers } from 'redux';
import { GridRootReducer } from 'react-redux-grid';
import { rootReducer } from 'react-redux-grid';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we probably don't want rootReducer here, we just want the Reducers right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's change this to Reducers and then I'm ready to merge!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right :). I've changed it to

import { Reducers as rootReducer } from 'react-redux-grid';

to clarify that Reducers is actually the rootReducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants