Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (8 years ago)
Author:
obenland
Message:

Plugin Directory: Update React client with latest changes.

This is largely a cleanup commit with some WIP around switching to node-wpapi.

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 */
     4import React, { Component, PropTypes } from 'react';
    25import { connect } from 'react-redux';
    36
     
    58 * Internal dependencies.
    69 */
    7 import { getBrowse } from 'actions';
     10import { fetchSection, fetchSections } from 'state/sections/actions';
    811import PluginSection from './plugin-section';
    912
    1013class PluginSectionContainer extends Component {
     14    static propTypes = {
     15        fetchSection: PropTypes.func,
     16        type: PropTypes.string.isRequired,
     17    };
     18
     19    static defaultProps = {
     20        fetchBrowse: () => {},
     21    };
     22
    1123    componentDidMount() {
    12         this.getBrowse();
     24        this.props.fetchSections();
     25        this.fetchSection();
    1326    }
    1427
    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();
    1831        }
    1932    }
    2033
    21     getBrowse() {
    22         this.props.dispatch( getBrowse( this.props.section.type ) );
     34    fetchSection() {
     35        this.props.fetchSection( this.props.type );
    2336    }
    2437
    2538    render() {
    26         return <PluginSection { ...this.props } />;
     39        return <PluginSection type={ this.props.type } />;
    2740    }
    2841}
    2942
    30 const mapStateToProps = ( state, ownProps ) => ( {
    31     plugins: state.browse[ ownProps.section.type ].slice( 0, 4 )
    32 } );
    33 
    34 export default connect( mapStateToProps )( PluginSectionContainer );
     43export default connect(
     44    null,
     45    {
     46        fetchSection,
     47        fetchSections,
     48    },
     49)( PluginSectionContainer );
Note: See TracChangeset for help on using the changeset viewer.