Skip to content

Instantly share code, notes, and snippets.

@anupvarghese
Created March 23, 2017 09:02
Show Gist options
  • Save anupvarghese/65ee5dc9422622b183e34cb0bf179768 to your computer and use it in GitHub Desktop.
Save anupvarghese/65ee5dc9422622b183e34cb0bf179768 to your computer and use it in GitHub Desktop.
import { combineReducers } from 'redux';
import level1 from './level1';
export default combineReducers({
data: level1,
});
export default {
someId: {
id: '123',
},
data: {
level1: {
someMap: [
{ id: '123' },
{ id: '456' },
]
},
}
}
import C from '../constants';
import initialState from '../initial_state';
import { fromJS } from 'immutable';
export default (state = fromJS(initialState.data), action) => {
switch (action.type) {
default: {
return state;
}
}
};
import React from 'react';
import { connect } from 'react-redux';
import { fromJS } from 'immutable';
const props = { someId: '123' };
const Simple = (props) => (
<div>testing</div>
);
export default connect(
(state, ownProps = props) => {
const someId = ownProps.someId;
const someMap = state.data
.getIn(['level1', 'someMap'])
.filter(some => {
console.log(some)
return some.get('id') === someId
});
return ({
someMap,
});
},
)(Simple);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment