title: How is state passed to selectors in a react-redux app?
body: <p>I came across an example, where the mapStateToProps function is using memoization. I was just wondering how the "state" parameter is passed onto memoized selectors. After looking at the docs for reselect as well as redux, it seems that the mapStateToProps can return a function which accepts state as its argument, and the connect decorator might be the one passing the state to it but am not sure. Can someone please shed some light?</p>
  
  <p><strong>views/tracklist/index.js</strong></p>
  
  <pre><code>const mapStateToProps = createSelector(
    getBrowserMedia,
    getPlayerIsPlaying,
    getPlayerTrackId,
    getCurrentTracklist,
    getTracksForCurrentTracklist,
    (media, isPlaying, playerTrackId, tracklist, tracks) =&gt; ({
      displayLoadingIndicator: tracklist.isPending || tracklist.hasNextPage,
      isMediaLarge: !!media.large,
      isPlaying,
      pause: audio.pause,
      pauseInfiniteScroll: tracklist.isPending || !tracklist.hasNextPage,
      play: audio.play,
      selectedTrackId: playerTrackId,
      tracklistId: tracklist.id,
      tracks
    })
  );
  
  export default connect(
    mapStateToProps,
    mapDispatchToProps
  )(Tracklist);
  </code></pre>
  
  <p><strong>core/tracklists/selectors.js</strong></p>
  
  <pre><code>export function getCurrentTracklist(state) {
  //  console.log(state);
    let tracklists = getTracklists(state);
    return tracklists.get(tracklists.get('currentTracklistId'));
  }
  
  export const getTracksForCurrentTracklist = createSelector(
    getCurrentPage,
    getCurrentTrackIds,
    getTracks,
    (currentPage, trackIds, tracks) =&gt; {
      return trackIds
        .slice(0, currentPage * TRACKS_PER_PAGE)
        .map(id =&gt; tracks.get(id));
    }
  );
  </code></pre>