Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/search/index.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (7 years ago)
- 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 */ 4 import React, { Component, PropTypes } from 'react'; 2 5 import { connect } from 'react-redux'; 3 6 7 /** 8 * Internal dependencies. 9 */ 4 10 import Search from './search'; 5 import { searchPlugins } from 'actions';11 import { fetchSearch } from 'state/search/actions'; 6 12 7 const SearchContainer = React.createClass( { 13 export 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 8 24 componentDidMount() { 9 this. searchPlugins();10 } ,25 this.fetchSearch(); 26 } 11 27 12 componentDidUpdate( previousProps) {13 if ( this.props.params.search Term !== previousProps.params.searchTerm) {14 this. searchPlugins();28 componentDidUpdate( { params } ) { 29 if ( this.props.params.search !== params.search ) { 30 this.fetchSearch(); 15 31 } 16 } ,32 } 17 33 18 searchPlugins() {19 this.props. dispatch( searchPlugins( this.props.params.searchTerm ));20 } ,34 fetchSearch() { 35 this.props.fetchSearch( this.props.params.search ); 36 } 21 37 22 38 render() { 23 39 return <Search { ...this.props } />; 24 40 } 25 } );41 } 26 42 27 const mapStateToProps = ( state, ownProps ) => ( { 28 plugins: state.search[ ownProps.params.searchTerm ] || null 29 } ); 30 31 export default connect( mapStateToProps )( SearchContainer ); 43 export default connect( 44 null, 45 { 46 fetchSearch, 47 }, 48 )( SearchContainer );
Note: See TracChangeset
for help on using the changeset viewer.