* The store gets a sort key. * Action creators and actions are added to set sort key. * A component is added which dispatches a reducer to update the state. * Album list get the sort key from the state and sort albums on render.
14 lines
413 B
JavaScript
14 lines
413 B
JavaScript
import React from 'react';
|
|
import { connect } from 'react-redux';
|
|
import SortSelect from '../components/sort-select';
|
|
import {setSortKey} from "../actions";
|
|
|
|
const mapStateToProps = state => ({
|
|
value: state.sortKey
|
|
});
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
handleOnChange: (key) => dispatch(setSortKey(key))
|
|
});
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SortSelect);
|