Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (7 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/search/index.jsx

    r4223 r5024  
    1 import React from 'react';
     1/**
     2 * External dependencies.
     3 */
     4import React, { Component, PropTypes } from 'react';
    25import { connect } from 'react-redux';
    36
     7/**
     8 * Internal dependencies.
     9 */
    410import Search from './search';
    5 import { searchPlugins } from 'actions';
     11import { fetchSearch } from 'state/search/actions';
    612
    7 const SearchContainer = React.createClass( {
     13export class SearchContainer extends Component {
     14    static propTypes = {
     15        fetchSearch: PropTypes.func,
     16        params: PropTypes.object,
     17    };
     18
     19    static defaultProps = {
     20        fetchSearch: () => {},
     21        params: {},
     22    };
     23
    824    componentDidMount() {
    9         this.searchPlugins();
    10     },
     25        this.fetchSearch();
     26    }
    1127
    12     componentDidUpdate( previousProps ) {
    13         if ( this.props.params.searchTerm !== previousProps.params.searchTerm ) {
    14             this.searchPlugins();
     28    componentDidUpdate( { params } ) {
     29        if ( this.props.params.search !== params.search ) {
     30            this.fetchSearch();
    1531        }
    16     },
     32    }
    1733
    18     searchPlugins() {
    19         this.props.dispatch( searchPlugins( this.props.params.searchTerm ) );
    20     },
     34    fetchSearch() {
     35        this.props.fetchSearch( this.props.params.search );
     36    }
    2137
    2238    render() {
    2339        return <Search { ...this.props } />;
    2440    }
    25 } );
     41}
    2642
    27 const mapStateToProps = ( state, ownProps ) => ( {
    28     plugins: state.search[ ownProps.params.searchTerm ] || null
    29 } );
    30 
    31 export default connect( mapStateToProps )( SearchContainer );
     43export default connect(
     44    null,
     45    {
     46        fetchSearch,
     47    },
     48)( SearchContainer );
Note: See TracChangeset for help on using the changeset viewer.