How to destructure an object to retrieve the return value from a method?
<p>I was working with immutability and redux and I am facing a problem which isn't grave but if there is a solution for it, then that would be great. Answer might be silly but since I am new to ES, I am thinking how can we achieve it.</p>

<p>Below is my reducer:</p>

<pre><code>import Immutable from 'immutable';
import { TODOYO } from '../constants/action-types';

const initialState = Immutable.Map({
  message: null,
});

export default function todos(state = initialState, action) {
  switch (action.type) {
    case TODOYO:
      return state.set('message', action.payload);
    default:
      return state;
  }
}
</code></pre>

<p>Below is my mapStateToProps function in a component:</p>

<pre><code>function mapStateToProps(state) {
  const message = state.todos.get('message');

  return {
    message,
  };
}
</code></pre>

<p>How can I destructure <code>state</code> to retrieve the message?</p>

<p>I was thinking something like this:</p>

<pre><code>const {
  todos: {
    message: get('message')
  }
} = state;
</code></pre>

<p>which is wrong. Is there a way to retrieve message?</p>