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/page/page.jsx

    r4223 r5024  
    1 import React from 'react';
     1/**
     2 * External dependencies.
     3 */
     4import React, { PropTypes } from 'react';
     5import { connect } from 'react-redux';
    26
    3 export default React.createClass( {
    4     displayName: 'Page',
     7/**
     8 * Internal dependencies.
     9 */
     10import { getPage } from 'state/selectors';
    511
    6     render() {
    7         if ( ! this.props.page ) {
    8             return (
    9                 <article className="page type-page">
    10                     <header className="entry-header">
    11                         <h1 className="entry-title"> </h1>
    12                     </header>
    13                     <div className="entry-content">
    14                         <section>
    15                             <div className="container"> LOADING </div>
    16                         </section>
    17                     </div>
    18                 </article>
    19             )
    20         }
    21 
     12const Page = ( { page } ) => {
     13    if ( page && page.title ) {
    2214        return (
    2315            <article className="page type-page">
    2416                <header className="entry-header">
    25                     <h1 className="entry-title">{ this.props.page.title.rendered }</h1>
     17                    <h1 className="entry-title">{ page.title.rendered }</h1>
    2618                </header>
    2719                <div className="entry-content">
    2820                    <section>
    29                         <div className="container" dangerouslySetInnerHTML={ { __html: this.props.page.content.rendered } } />
     21                        <div className="container" dangerouslySetInnerHTML={ { __html: page.content.rendered } } />
    3022                    </section>
    3123                </div>
    3224            </article>
    33         )
     25        );
    3426    }
    35 } );
     27
     28    return (
     29        <article className="page type-page">
     30            <header className="entry-header">
     31                <h1 className="entry-title"> </h1>
     32            </header>
     33            <div className="entry-content">
     34                <section>
     35                    <div className="container"> LOADING </div>
     36                </section>
     37            </div>
     38        </article>
     39    );
     40};
     41
     42Page.propTypes = {
     43    page: PropTypes.object,
     44};
     45
     46Page.defaultProps = {
     47    page: {},
     48};
     49
     50export default connect(
     51    ( state ) => ( {
     52        page: getPage( state ),
     53    } ),
     54)( Page );
Note: See TracChangeset for help on using the changeset viewer.