Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/archive/browse/index.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/archive/browse/index.jsx
r4223 r5024 1 import React from 'react'; 1 /** 2 * External dependencies. 3 */ 4 import React, { Component, PropTypes } from 'react'; 2 5 import { connect } from 'react-redux'; 3 6 4 import { getBrowse } from 'actions'; 7 /** 8 * Internal dependencies. 9 */ 10 import { fetchSection, fetchSections } from 'state/sections/actions'; 11 import { getSection } from 'state/selectors'; 5 12 import Browse from './browse'; 6 13 7 const BrowseContainer = React.createClass( { 14 export class BrowseContainer extends Component { 15 static propTypes = { 16 fetchSection: PropTypes.func, 17 params: PropTypes.object, 18 }; 19 20 static defaultProps = { 21 fetchSection: () => {}, 22 params: {}, 23 }; 24 8 25 componentDidMount() { 9 this. getBrowse();10 } ,26 this.fetchSection(); 27 } 11 28 12 componentDidUpdate( previousProps) {13 if ( this.props.params.type !== p reviousProps.params.type ) {14 this. getBrowse();29 componentDidUpdate( { params } ) { 30 if ( this.props.params.type !== params.type ) { 31 this.fetchSection(); 15 32 } 16 } ,33 } 17 34 18 getBrowse() { 19 this.props.dispatch( getBrowse( this.props.params.type ) ); 20 }, 35 fetchSection() { 36 if ( ! this.props.section ) { 37 this.props.fetchSections(); 38 } 39 this.props.fetchSection( this.props.params.type ); 40 } 21 41 22 42 render() { 23 return <Browse { ...this.props} />;43 return <Browse type={ this.props.params.type } />; 24 44 } 25 } );45 } 26 46 27 const mapStateToProps = ( state, ownProps ) => ( { 28 plugins: state.browse[ ownProps.params.type ] 29 } ); 30 31 export default connect( mapStateToProps )( BrowseContainer ); 32 33 47 export default connect( 48 ( state, { params } ) => ( { 49 section: getSection( state, params.type ), 50 } ), 51 { 52 fetchSection, 53 fetchSections, 54 }, 55 )( BrowseContainer );
Note: See TracChangeset
for help on using the changeset viewer.