C
C
crysiscaramel2020-06-29 18:12:12
React
crysiscaramel, 2020-06-29 18:12:12

How to work with props if you use immutable js in conjunction with redux?

Let's say there is a store

const initState = Immutable.fromJS({
  data: [],
});

export default function reducer(state = initState, action) {
  switch (action.type) {
    case actions.SET_DATA: {
      const { payload } = action;
      return state.merge({ data: payload })
}


there is a component
const Component = (props) => {
const { data } = props;
   return {
      <div> data </div>
    }
}
const mapStateToProps = (state) => {
   data: state.data || state.data.toJS()
}
Component.defaultValue = {
data: ??????
}


What is better to write in defaultValue and is it worth using the toJS() method for state props to convert immutable SET and MAP into regular arrays and objects?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question