{"size": 1320, "ext": "js", "max_stars_repo_path": "react/site/index/index.main.js", "max_stars_repo_name": "defyma/yii2-react-basic", "max_stars_repo_stars_event_min_datetime": "2019-09-21T06:54:24.000Z", "max_stars_repo_stars_event_max_datetime": "2019-09-21T06:54:24.000Z", "max_issues_repo_path": "react/site/index/index.main.js", "max_issues_repo_name": "defyma/yii2-react-basic", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "react/site/index/index.main.js", "max_forks_repo_name": "defyma/yii2-react-basic", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.1304347826, "max_line_length": 76, "alphanum_fraction": 0.4810606061}
/**
 * Defy Ma
 * defyma.com
 */
/*jshint esversion: 6 */
/*jshint ignore:start*/

import React, {Component} from 'react';
import ReactDOM from 'react-dom';

import App from '../../components/App'

class Main extends Component {
	constructor(props) {
        super(props);
        this.state = {
            isLoaded: false,
            message: ""
        };
    }

    componentDidMount() {
    	this.loadData();
    }

    loadData() {
		this.setState({
			isLoaded: false
		})

		/**
		 * $ from jQuey in global window, not from import
		 */
    	$.ajax({
    		method: 'GET',
    		url: window.__MYSITE__ + 'site/getdata',
    		type: 'json',
    		success: (result) => {
    			if(result.success) {
    				this.setState({
    					isLoaded: true,
    					message: result.message
    				})
    			}
    		},
    		error: (err) => {
    			console.log("error get data");
    		}
    	})
    }


    render() {
        return (
            <div>

                Hello From yii2-react
                <br />
                Edit This file on 'react/site/index/index.main.js'	
                <br />
                <br />
                {this.state.isLoaded ? this.state.message : "Loading ...."}
            </div>
        );
    }
}

ReactDOM.render(<App><Main /></App>, document.querySelector("#root-react"));
