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/page/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';
    3 import find from 'lodash/find';
    46
    57/**
     
    79 */
    810import Page from './page';
    9 import { getPage } from 'actions';
     11import { fetchPage } from 'state/pages/actions';
    1012
    11 const PageContainer = React.createClass( {
     13class PageContainer extends Component {
     14    static propTypes = {
     15        fetchPage: PropTypes.func,
     16        route: PropTypes.object.isRequired,
     17    };
     18
     19    static defaultProps = {
     20        fetchPage: () => {},
     21    };
     22
    1223    componentDidMount() {
    13         this.getPage();
    14     },
     24        this.fetchPage();
     25    }
    1526
    16     componentDidUpdate( previousProps ) {
    17         if ( this.props.route.path !== previousProps.route.path ) {
    18             this.getPage();
     27    componentDidUpdate( { route } ) {
     28        if ( this.props.route.path !== route.path ) {
     29            this.fetchPage();
    1930        }
    20     },
     31    }
    2132
    22     getPage() {
    23         this.props.dispatch( getPage( this.props.route.path ) );
    24     },
     33    fetchPage() {
     34        this.props.fetchPage( this.props.route.path );
     35    }
    2536
    2637    render() {
    27         return <Page { ...this.props } />;
     38        return <Page />;
    2839    }
    29 } );
     40}
    3041
    31 const mapStateToProps = ( state, ownProps ) => ( {
    32     page: find( state.pages, { slug: ownProps.route.path } )
    33 } );
    34 
    35 export default connect( mapStateToProps )( PageContainer );
     42export default connect(
     43    null,
     44    {
     45        fetchPage,
     46    }
     47)( PageContainer );
Note: See TracChangeset for help on using the changeset viewer.