Advertisement
andybeak

FilterListingContainer.js

Jun 8th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { connect } from 'react-redux';
  4.  
  5. import { toggleTag } from '../actions/filters';
  6.  
  7. class FilterListingContainer extends Component {
  8.     static propTypes = {
  9.         Layout: PropTypes.func.isRequired,        
  10.         tags: PropTypes.arrayOf(PropTypes.shape()).isRequired,        
  11.     }
  12.  
  13.     clickHandler = (newState, buttonId) => {
  14.         console.log("container " + newState + " " + buttonId);
  15.     }
  16.        
  17.     render = () => {                
  18.         const { Layout, tags } = this.props;        
  19.         return (
  20.           <Layout
  21.             tags={tags}
  22.             onStateChange={this.clickHandler}            
  23.           />
  24.         );
  25.     }
  26. }
  27.  
  28.  
  29. const mapStateToProps = state => ({    
  30.     tags: state.tagfilterreducer.tags || [],
  31. });
  32.  
  33. function mapDispatchToProps(dispatch) {
  34.     return {
  35.         clickHandler: (newState, buttonId) => {                      
  36.             dispatch({
  37.                 type: 'TOGGLE_FILTER_TAG',
  38.                 data: buttonId,
  39.             })        
  40.         }
  41.     }
  42. }
  43.  
  44. export default connect(mapStateToProps, mapDispatchToProps)(FilterListingContainer);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement