Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/front-page/plugin-section/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/front-page/plugin-section/index.jsx
r4223 r5024 1 import React, { Component } from 'react'; 1 /** 2 * External dependencies. 3 */ 4 import React, { Component, PropTypes } from 'react'; 2 5 import { connect } from 'react-redux'; 3 6 … … 5 8 * Internal dependencies. 6 9 */ 7 import { getBrowse } from 'actions';10 import { fetchSection, fetchSections } from 'state/sections/actions'; 8 11 import PluginSection from './plugin-section'; 9 12 10 13 class PluginSectionContainer extends Component { 14 static propTypes = { 15 fetchSection: PropTypes.func, 16 type: PropTypes.string.isRequired, 17 }; 18 19 static defaultProps = { 20 fetchBrowse: () => {}, 21 }; 22 11 23 componentDidMount() { 12 this.getBrowse(); 24 this.props.fetchSections(); 25 this.fetchSection(); 13 26 } 14 27 15 componentDidUpdate( previousProps) {16 if ( this.props. section.type !== previousProps.section.type ) {17 this. getBrowse();28 componentDidUpdate( { type } ) { 29 if ( this.props.type !== type ) { 30 this.fetchSection(); 18 31 } 19 32 } 20 33 21 getBrowse() {22 this.props. dispatch( getBrowse( this.props.section.type ));34 fetchSection() { 35 this.props.fetchSection( this.props.type ); 23 36 } 24 37 25 38 render() { 26 return <PluginSection { ...this.props} />;39 return <PluginSection type={ this.props.type } />; 27 40 } 28 41 } 29 42 30 const mapStateToProps = ( state, ownProps ) => ( { 31 plugins: state.browse[ ownProps.section.type ].slice( 0, 4 ) 32 } ); 33 34 export default connect( mapStateToProps )( PluginSectionContainer ); 43 export default connect( 44 null, 45 { 46 fetchSection, 47 fetchSections, 48 }, 49 )( PluginSectionContainer );
Note: See TracChangeset
for help on using the changeset viewer.